Reputation: 379
I am building an augmented reality app using ar foundation. I need to detect a collision between two cubes. The cubes both have a box collider and a rigid body attached to them. When I run the scene in the editor everything works fine but when I build it for android and then test it won't detect any collisions. Could it be because when one of the cubes is spawned it is already touching the other one?
I'm pretty sure its an issue with Unity and not my code but here is some of it just in case. I have also posted on Unity Answers here
void OnCollisionEnter(Collision collision)
{
Debug.Log(collision.gameobject.name);
if (collision.gameObject.tag == col_tag)
{
if (collision.gameObject != first && first != null)
{
//stuff
}
else
{
point = collision.contacts[0].point;
first = collision.gameObject;
}
}
}
Upvotes: 1
Views: 889
Reputation: 96
try using void OnTriggerEnter. In the box collider activate IsTrigger and try to use this script:
void OnTriggerEnter (Collider collision)
{
Debug.Log(collision.gameobject.name);
if (collision.gameObject.tag == "col_tag")
{
if (collision.gameObject != first && first != null)
{
//stuff
}
else
{
point = collision.contacts[0].point;
first = collision.gameObject;
}
}
}
Upvotes: 1