Home > Net >  How do you play animation in unity when you walk through a trigger
How do you play animation in unity when you walk through a trigger

Time:01-03

I’m making a horror vr game in unity with the ovr player controller and I’m trying to figure out how to make an animation I made in blender play behind me when ever I walk into a certain box trigger.

CodePudding user response:

You could use something along the lines:

[SerializeField] private GameObject player;
[SerializeField] private Animation animation;

private void OnTriggerEnter(Collision other)
{
    if (other.gameObject == player)
        animation.Play();
}

The player and animation fields need to be initialized from the inspector.

  • Related