Help with a door slam trap
Hello All,
I am having a slight problem with this door trap I am creating for my game. I created 2 scripts one on the door to handle the animation of the door slamming and the other on the trigger object to trigger the animation. The problem is that for some reason it is not triggering the animation. My question is where is the problem is it in my code or in the animator itself. So I have pasted the code for both my scripts here to find out if there is an issue there
Trigger Code:
public AudioClip slam;
void OnTriggerEnter(Collider player)
{
if(player.tag == "Player")
{
jaildoor.b_close = true;
AudioSource.PlayClipAtPoint(slam, transform.position, 100f);
}
}
Door Code:
public static bool b_open;
public static bool b_close;
public Animator jailanim;
void Start ()
{
Animation();
jailanim = GetComponent<Animator>();
}
void Animation()
{
if (b_close)
{
jailanim.SetBool("close", true);
}
else if (b_open)
{
jailanim.SetBool("open", true);
}
}
Please any help would be appreciated
Comment
Your answer
Follow this Question
Related Questions
Mecanim animation playing once on button press 2 Answers
Check for collision while animating 0 Answers
Can't trigger animation on Collider2D 0 Answers
ANIMATION STRANGELY DOES NOT PLAY 0 Answers