- Home /
Collision detection delayed
I've run into a very odd problem that I'm not entirely sure why it's happening. Basically, I'm using Mecanim to control character movement, and one of the transitions is from walking to idle if the character walks into a simple box collider.
For whatever reason, the first time the character passes through the collider, it doesn't execute my code. I know the collision is detected, because another thing it does is switch between cameras, which works. But the character keeps walking a circle. It's only the second time around (when they walk into it again) that it actually sets the boolean in charge of changing states to idle.
It's even odder because it used to work, but after I moved the position of the box a bit, it stopped working. But there's literally nothing else besides the character with another collider, so it's not like there's anything getting in the way.
My code is here:
public class triggerIdle2 : MonoBehaviour {
public Animator anim;
public TriggerCameras trigger;
//public SceneFade fader;
void OnTriggerEnter (Collider col)
{
anim.SetBool ("turnLeft", false);
trigger.SelectCamera (1);
//fader.endingScene = true;
}
}
I'm not sure if it makes a difference, but one thing that is a bit different is that I'm using Invoke to trigger the walk animation after a 2 second delay, to give the camera time to finish zooming.