- Home /
OnTriggerEnter called one step too late
I have finally managed to isolate this problem to a configuration of three boxes without rotation. Before I submit a bug report I would like to make sure that this is not a user mistake.
Floor: create a new box object at (992, -144, 0) with a scale of (1984, 352, 200)
Wall: create a new box object at (928, 160, 0) with a scale of (640, 320, 200)
Player: create a new box object at (414.5, 32, 0) with a scale of (135, 390, 100)
add a rigid body with trigger to the player and turn off gravity
add the following test script to the player
using UnityEngine;
public class SpecialScript : MonoBehaviour
{
public void Start() { rigidbody.velocity = new Vector3(1200, 0, 0); }
public void OnTriggerEnter(Collider other) { this.collisionDetection(other); }
public void OnTriggerStay(Collider other) { this.collisionDetection(other); }
public void OnTriggerExit(Collider other) { this.collisionDetection(other); }
private void collisionDetection(Collider other)
{
if (other.name.Equals("Floor"))
Debug.Log("You are here " + rigidbody.collider.bounds.max.x);
if (other.name.Equals("Wall"))
Debug.Log("You are here " + rigidbody.collider.bounds.max.x + " Wall is there " + other.collider.bounds.min.x);
}
}
The player moves to the right along the X axis. The left boundary of the wall is at X=608. The player detects the wall when the player's right boundary is at X=650. On the previous step the player's right boundary is at X=626. It fails to detect the wall but is does detect the floor object.
In summary, the player's trigger event is fired one step too late for the collision between the player and the wall.
Your answer
Follow this Question
Related Questions
Why are my OnTriggerEnter2D events firing only on android in a situation they shouldnt be firing? 0 Answers
Disable Mesh Collider Trigger 1 Answer
Collision Matrix not working properly 0 Answers
Multiple triggers on one object, senses 1 Answer
'PlayerBlue' AnimationEvent 'InAction' has no receiver! Are you missing a component? 1 Answer