K
K
KeysCG2021-08-20 18:23:06
Unity
KeysCG, 2021-08-20 18:23:06

How to implement the appearance of the model and the playback of the animation through the trigger?

Good day!
I want to try to make the construction of a building on the click of a button in a specific place, but I don’t understand how this can be implemented.
The bottom line is, there is a building model with construction animation, you need to make it so that when you go into the trigger, the model appears and the animation plays, how best to implement this?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Y
Yura Milevsky, 2021-11-13
@KeysCG

public GameObject Building;
    public Animator animator;

    void OnTriggerEnter(Collider other)
    {
        if other.tag == "*Тэг вашего игрока*"
        {
            animator.Play("*Название анимации строительства в аниматоре*");
        }
    }

That's so easy and simple.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question