- Home /
Animation issue (OnTriggerEnter) ***SOLVED***
hey guys,
I have a quick question,
I want the player to step on a trap and then that triggers 4 doors to move. The animation is attached to the trigger. it is set as a tigger with a box collider and everything. The issue is the animation just plays when the game is played. the animation is always playing.this is not what i want.
Here is the script I have, but it doesn't do what it should.
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class TrapTrigger : MonoBehaviour
{
public GameObject Trigger;
public Animator anim;
void OnTriggerEnter(Collider other)
{
if (other.tag == "Player")
{
Trigger.GetComponent<Animator>().Play("doortrap");
anim.GetComponent<Animator>().Play("doortrap");
}
}
}
any help is welcomed.
Answer by bunnynsnake · Aug 06, 2018 at 01:46 AM
Solved
Added a bool component to the animator and set it to true. then added it to the transition and set that false.
Your answer
![](https://koobas.hobune.stream/wayback/20220612172243im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Revers Object Transfrom using an array problem in UI !! 0 Answers
Why isn't LateUpdate detecting changes from Update? 1 Answer
Checking Animtor State Info With Hash Name 2 Answers
Issue With Vector3 and Transform 1 Answer
this.transform.FindChild(x) and GameObject.Find(x) returning (apparently?) different results 1 Answer