Reputation: 1
I have a parent element ("MainSquare") and 4 child elements ("redCube, blueCube, yellowCube and greenCube").
I need to detect a collision between the falling "Enemy Square" and the child elements.
Upvotes: 0
Views: 52
Reputation: 460
Do Code like that similar to your approaches...
void OnCollisionEnter(Collision col)
{
if(col.gameObject.name.equals("redCube"))
{
............
..........
}
else if(col.gameObject.name.equals("blueCube"))
{
.........
........
}
................
................
}
But in your sense,you also have to set space or any button down for rotating your parent-cube in Y Rotation for Get Detection similar to enemy. As I understand Problem as such I replied sorry for any poor description because I'm new here too.
Upvotes: 2