Question by
nischalk59 · Jun 15, 2020 at 04:01 PM ·
animationbooleancodepage
Unity Animation
So I was following this one video from youtube: https://www.youtube.com/watch?v=Xnyb2f6Qqzg Code:
static Animator anim; float speed = 2.0f; float rotSpeed = 2.0f;
void Start()
{
anim = GetComponent<Animator>();
anim.SetBool("IsWalking", false);
}
void Update()
{
float y = Input.GetAxis("Vertical") ;
float x = Input.GetAxis("Horizontal")*rotSpeed;
y += Time.deltaTime;
x += Time.deltaTime;
transform.Translate(0, 0, y);
transform.Rotate(0, x, 0) ;
if (y != 0)
{
anim.SetBool("IsWalking", true);
Debug.Log("IsWalking");
}
else
{
anim.SetBool("IsWalking", false);
}
}
Everytime, I click play the character stars walking/moving eventhough It is only supposed to do that when I move the character. It somehow thinks the condition is true everytime. Please help.
annotation-2020-06-15-115918.jpg
(222.9 kB)
Comment
Your answer
Follow this Question
Related Questions
Vector3.Distance keeps growing 0 Answers
How to get quick animation transition variants on start? 0 Answers
Boolean prevent script from working 0 Answers
Animator Boolean not changing to true in C#, 0 Answers
Call animation only once? 1 Answer