Hi,
Using a script, I attached 10 meshes to an empty object (the parent). Now, I would like to handle collisions between one of these objects and a wall. In the script I added OnCollisionEnter(), but how can I select which object collides?
void Start()
{
mesh_1.transform.parent = this.transform;
mesh_2.transform.parent = this.transform;
}
void OnCollisionEnter(Collision col)
{
if(col.gameObject.tag == "wall")
{
print("hit"); // Doesn't work?
}
/* Pseudocode:
* if mesh1 collides with a wall: print "mesh1 hits",
* else: print "mesh2 hits"
*/
}
Thanks