How to setup a simple animation system for 8Directions behaiour

1

Stats

2,648 visits, 4,428 views

Tools

Translations

This tutorial hasn't been translated.

License

This tutorial is licensed under CC BY 4.0. Please refer to the license text if you wish to reuse, share or remix the content contained within this tutorial.

Published on 7 Jul, 2012. Last updated 19 Feb, 2019

The idea is to build a string that corresponds to the name of the animation you want to play. The only requirment is that you have a strict naming convention on your animations.

The first thing you need to do is to make sure your animations are properly named. I chose to do Action+Direction but you're welcome to use whatever feels natural to you.

Second, you check which direction the player is facing and add that to a global string (CurrentAngle):

Then you simply do conditions to check what the player is doing and combine the CurrentAngle with the right action to set the appropriate animation.

Note that in my particular example I have one arrow sprite called "Player" that drives the controls and behaviour and one sprite called "PlayerSprite" that performs all the visuals. On runtime I hide "Player" and set the "PlayerSprite" the same position as "Player".

You can download the example scene here

Hope this helps and good luck!:)

  • 2 Comments

  • Order by
Want to leave a comment? Login or Register an account!