Answer the question
In order to leave comments, you need to log in
How to stop a moving object?
Hello.
Put the zombie model. Put a cube on it. The cube was made invisible. The cube contains a box collider and a rigid body.
When I shoot a zombie 5 times, it should fall (animation) and stop. However, he falls and falls and falls, and all the while he is still moving. I set speed to 0, I wrote
transform.position = Vector3.zero;
But it doesn't give the desired result. How can I make it stop moving towards me and the animation only works once?
Answer the question
In order to leave comments, you need to log in
Resolved:
In order for the zombie to stop moving after falling, you need to check the box where FreezyRotation is.
And so that the death animation does not repeat forever, you need to set wrapMode to Once
and write the following code:
//сначала заводим переменную isDead
public bool isDead = false;
//затем в функции Update
if (!isDead)
{
zombieIsDead.Play("back_fall");
Destroy(TheEnemy, 2);
isDead = true;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question