|
Basically I have a pixelated creature made up of these cubes and when hit by a bullet I want them to fall apart. So heres the code I wrote but for some reason it does not work.
(comments are locked)
|
|
You can loop through all the children in the object's hierarchy and unparent them and give them all colliders and rigidbodies. do something like this:
(comments are locked)
|
|
Is the OnTriggerEnter() method even triggered? Try putting a Debug.Log("blah") in there to be sure... Do you have a collider on the character? Is it set as a trigger collider? Is there a RigidBody component on the bullets or the character? More info will help :)
(comments are locked)
|

I'd get rid of this bit (var instance : GameObject = ) because you don't use the reference. Just keep the instantiate part. Also you might want to randomise the rotation and placement a bit as you'll get 20 objects in the same spot which would lag out the game as the physics tries to sort out the displacements.