![]() That’s not yet completed! As you can see, our character is not moving! And it’s not changing direction…īecause we are using Rigidbody (and physics system) for our movement, we should only move our character in FixedUpdate method! So the result of that code is… Walk animation in action! Public const string ANIMATION_AIRSPEED_KEY = "AirSpeed" Public const string ANIMATION_INAIR_KEY = "InAir" Public const string ANIMATION_SPEED_KEY = "Speed" / This class contains constant strings for use in code. I’m using that to store all of my string keys, so I won’t make any typos in my code. HorizontalInput = Input.GetAxisRaw("Horizontal") ĬharacterAnimator.SetFloat(Keys.ANIMATION_SPEED_KEY, Mathf.Abs(animSpeed)) We can also set the value for our animator to make our character “walk”. The next step will be to configure walk speed and read player input. Public class CharacterMovement : MonoBehaviour We will need here Animator and Rigidbody2D. Let’s start with gathering necessary references for our component. This script will read player input and translates it into a character walk. So it’s finally time to make our character walk! To do that, we would need to create a little script that will be responsible for that. You should start reading there before reading this post. This post is a continuation of Animated Character 2D in Unity (Part 1). ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |