Hello! I've been working on a system of automatic doors which, when the player hits their trigger, will open automatically, and close after a time. This side of it works perfectly, but now I'm attempting to cobble up what happens when they're locked.
My thought was something along these lines:
void OnTriggerEnter(Collider col){
if (doorLocked == true) {
// Which gameobject has just collided with the trigger?
GameObject subject = col.gameObject;
Animator subAnim = subject.GetComponent<Animator> ();
subAnim.SetFloat("Speed",0.0f);
}
}
The plan here was to drop the player's "Speed" mecanim parameter to 0.0, causing the player to stop walking. This didn't work (unsurprisingly), which led to me to think that other mechanisms are driving the player character's movement beyond the simple speed value, such as where they're going, paths to get there, etc.
Is there, therefore, any means by which I can tell a character to stop moving when they hit the trigger collider?
Comments