Question by
RRisCool · May 01, 2018 at 07:27 AM ·
animationprogramming
I have some problems with my animation.help PLEASE!
So, I have written this basic movement code. It's supposed to move and play the run animation. But instead of playing the animation, It just keeps starting over again and again, and when I release the move button, it just goes back to idle. Here is the code.
void Start () {
//define Rigidbody and animator
rb = GetComponent<Rigidbody>();
anim = GetComponent<Animator>();
}
// Update is called once per frame
void FixedUpdate () {
//define horizontal and vertical floats
h = Input.GetAxisRaw("Horizontal");
v = Input.GetAxisRaw("Vertical");
Move(v , h);
Animating(h, v);
}
//Moves
void Move(float v,float h)
{
//Make the vector which takes input
movement.Set(h, 0f, v);
//move with vector with speed and time over seconds
rb.MovePosition(transform.position + movement);
}
//Perform the animations
void Animating(float h, float v)
{
isRunning = h != 0f || v != 0f;
anim.SetBool("IsRunning", isRunning);
Debug.Log(isRunning);
}
}
Comment
Your answer
Follow this Question
Related Questions
Multiple animations on the same GameObject won't work 0 Answers
How to add alternate idle directions to a top-down game 0 Answers
How to add alternate idle directions to a top-down game 0 Answers
Animations created in Runtime 0 Answers
How can I specify points attached to a sprite that move with the animation? 0 Answers