I need to distinguish the two objects of a collision. They are instances of the same prefab, so they have the same name, the same scripts components etc. But i need that when they collide the first one moves an x = +1 and the second one moves an x = -1. I wrote this code but it doesn’t seem to affect the behaviour of the two instances:
function OnTriggerStay (col : Collider){
if ((col.gameObject.tag == "Enemy"){
col.gameObject.transform.position += Vector3(1,0,0);
gameObject.transform.position -= Vector3(1,0,0);
}
}
I need Unity to distinguish the collider object and the collided object and make the two move a bit in opposite directions. Can you help me?