How to set the speed to 0
I want to make an attack animation, but when i play the animation while running the player is still moving. I tried to change rigidbody's velocity and more but nothing seemed to help. So how could i stop the player when the attack animation is playing?
Good day
Dont think you need to explain something else if want help....? How is the plyee moving? With transform.Translate?? Or with rigidbody.addforce ? Orchanging its position? Or with navmeshsysgem?...
Yeah, you are right. I am using rigidbody.addforce.
Answer by Rynbernsz · Aug 31, 2018 at 09:25 PM
I would think that you could achieve this through States. And when you're attacking, the player would be in a "fighting" state. While in this fighting state, try this:
Rigidbody2D rb2d; rb2d = GetComponent(); rb2d.velocity = new Velocity2(0f, 0f);
.
And then switch back to "idle" state or whatever other state after the attackin animation is finished. From the comments, it looks like you're moving a dynamic rigidbody2D; is that correct? ,You could use States and have the rb2d.velocity = new Vector2 (0f, 0f);
when the character is in attacking State.
Based on the comments, it looks like this is a dynamic body; is that correct? Have you tried something like this, yet?
I tried changing the velocity, but I see I did it wrong. I'll try your method, thanks!