Reputation: 41
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.
Upvotes: 1
Views: 166
Reputation: 41
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.
Upvotes: 1