- Home /
Question by
ndauchot · Apr 13, 2019 at 12:09 PM ·
animatortriggeranimationstriggering animation box collider
Animation triggers are not firing
Hello,
I have two gameObjects, my GameController (e.g. GameController) and a GameObject (e.g. Troll). The troll has an animator connected to it with a trigger attached to it to switch between Dance > Dead. The trigger is called "TrollDie"
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ScoreUp : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
private void OnTriggerEnter(Collider coll)
{
if (coll.gameObject.tag == "GameController") {
GetComponent<Animator>().SetTrigger("trollDie");
}
Debug.Log("TestCollision");
}
}
What I want is for when the user hits the troll with the controller, the troll's animation triggers to the Die animation. Unfortunately this only works when the troll enters the scene on top of the GameController collider, forcing the trigger event. This is how I want it to work no matter what. The console is detecting the collision, but the trigger will not happen.
Has anyone experienced this before? I feel like I'm experiencing a bug.
Comment