1

If I instantiate a prefab like so:

GameObject asteroid = GameObject.Instantiate(thing2spawn);
//then set the location and some other stuff

The prefabbed asteroid's collisions do not register at all, but If I simply drag the asteroid into the scene, the collisions work exactly as expected.

1 Answers1

1

Figured it out.

My asteroid object has two child objects which contain colliders that do different things. Hitting a certain part of the asteroid heals you, while hitting the other part damages you. These two children had rigid body components so when I set the speed of the asteroid (the parent object) in code, the two children wouldn't move with it. So it seemed like the colliders weren't working when really they were just left behind in some other place. Removing the rigid bodies from the children fixed the problem.

Weird.

  • As you find out, you can't really have Rigidbody as children of another one, or else you'll encounter random non-working behaviours like this. – Kamalen Apr 03 '17 at 13:05