1
1
1bd_1l_Bari2017-07-24 20:34:19
Game development
1bd_1l_Bari, 2017-07-24 20:34:19

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

1 answer(s)
1
1bd_1l_Bari, 2017-07-24
@1bd_1l_Bari

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;
            }

The zombie will fall and disappear after 2 seconds.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question