Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lernen Controle Your Animation with Script | Unity-Animationssystem
Kampfspiel in Unity

Controle Your Animation with Script

Swipe um das Menü anzuzeigen

In Unity, controlling animations with scripts allows you to create dynamic and interactive experiences within your games or applications. This approach enables you to trigger animations, change their playback speed, blend between animations, and respond to various events during runtime.

Controlling Parameters

animator.SetBool("isRunning", true)
  • animator: This is a reference to an Animator component attached to a GameObject in Unity;
  • SetBool(): This is a method provided by the Animator component. It is used to set the value of a Boolean parameter in the Animator Controller, which is responsible for controlling the animations;
  • "isRunning": This is the name of the boolean parameter in the Animator Controller;
  • true: This is the value that we are setting the "isRunning" parameter to.

Changing Scale

Changing the x scale of our character flips it because scaling negatively along the x-axis mirrors the sprite horizontally. Most 2D sprites face right by default. Flipping the scale reverses this. The character appears to face the opposite direction. This happens due to the way Unity interprets negative scale values, flipping the visual representation of the sprite around its centerline, altering its orientation.

Player with Position X Scale

S1V4P1

Player with Negative X Scale

S1V4P2

Additional Resources

War alles klar?

Wie können wir es verbessern?

Danke für Ihr Feedback!

Abschnitt 1. Kapitel 5

Fragen Sie AI

expand

Fragen Sie AI

ChatGPT

Fragen Sie alles oder probieren Sie eine der vorgeschlagenen Fragen, um unser Gespräch zu beginnen

Abschnitt 1. Kapitel 5
some-alt