Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Controle Your Animation with Script | Unity Animation System
Fighting Game in Unity
course content

Contenido del Curso

Fighting Game in Unity

Fighting Game in Unity

1. Unity Animation System
2. Player Behavior
3. Enemy Behavior
4. Improve the Game
5. Improve the Flappy Bird Game

bookControle Your Animation with Script

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: 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

Player with Negative X Scale

Additional Resources

¿Todo estuvo claro?

¿Cómo podemos mejorarlo?

¡Gracias por tus comentarios!

Sección 1. Capítulo 5
some-alt