I have a box collider around my camera, which is a trigger that is supposed to detect if the camera is close to the terrain. Most of the time it works, but sometimes the bool is set to ‘false’ even though the trigger is IN the collider(terrain). This happens because the ‘OnTriggerExit’ is the last thing that was called, which I’m not really sure how or why it happens.
Here is the code:
public CameraController camController;
private void OnTriggerExit(Collider other)
{
camController.isColliderTouching = false;
}
private void OnTriggerEnter(Collider other)
{
camController.isColliderTouching = true;
}
Now I did try replacing the ‘OnTriggerEnter’ with ‘OnTriggerStay’ AND even having both at the same time, but it didn’t resolve the issue. Somehow, it still manages to ignore(?) it at times.
I also tried changing the collision detection method on the collider, but unfortunately that did not work out either.