Update: I have tried doing it all over again, this is still happening. Any other ideas?
Hello,
As an awful way to double check for a collision, I’ve created 4 colliders(divided in 4 directions) attached to an empty gameobject.
Each of the object turns a boolean from the empty gameobject script - true with OnTriggerEnter and false OnTriggerExit.
When all of them are true something (not sure what yet) is going to happen.
The problem is the following: while my AI is moving (so are the colliders) and if they move quickly they cancel each other somehow that they are unable to be all true although all of them are colliding with the triggers.
Here is an example of the code I use on one of the colliders:
function OnTriggerEnter(hit:Collider)
{
if(hit.collider.tag == "Fence")
{
var gameObject = GameObject.FindGameObjectWithTag("DoubleCheck");
var script = gameObject.GetComponent(DoubleCheckAI);
script.topDcheck = true;
}
}
function OnTriggerExit(hit:Collider)
{
var gameObject = GameObject.FindGameObjectWithTag("DoubleCheck");
var script = gameObject.GetComponent(DoubleCheckAI);
script.topDcheck = false;
}
Notes: I have kinematic rigidbodies attached on the colliders. I have the colliders set to isTrigger.
Any help on this would be greatly appreciated because I’ve never encountered this until now…
EDIT (Scenario information): Certainly.
My AI is moving constantly (currently the AI is a sphere with a sphere collider).
Attached to my AI I have an empty game object with a cube collider to count the number of fences. Also attached to the AI I am doing a double check of the collision using 4 box colliders (for 4 directions) - these are the problem.
The fences are prefabs instantiated on click + drag in a certain direction.
The idea of the game is to capture the AI between 4 fences - that is what isn’t working for me at all times.
Due to the issue with the double check I am not always seeing that the AI is captured if it moves. If my AI would be static if wouldn’t be a problem as I’ve tried moving the colliders manually while pausing the unity player.
Not sure what to do next…