Missile Won't Attach as a Child of an Airplane. Why?
I have an airplane model that I want to attach a missile to. In the hierarchy, I have an airplane object with the motion script attached, and children to this are:
the airplane model hierarchy
a collider hierarchy
a weapons system empty
I dragged the missile prefab to the weapons system empty: this works when dragging the airplane around in the editor. But when the game is played, the missile just drops to the ground with its own gravity, separate from the airplane. What is wrong? Can this object not have a rigidbody?
I tried:
adding a joint
deactivating my missile script
using a standard game object instead of a prefab
However, the missile still wants to use its own coordinates instead of remaining attached to the airplane. I plan to detach the missile later when it must be shot.
Answer by DenisGLabrecque · Sep 03, 2018 at 02:31 PM
The answer to this is that an object with a Rigidbody separates from its parent in Unity. This is Unity's way of enforcing only one Rigidbody per hierarchy.
To connect two rigidbodies, use FixedJoint on the child GameObject.
Your answer
Follow this Question
Related Questions
Foreach loop not going through all elements 1 Answer
Child objects shifts parent's origin,origin changes to center of mesh 1 Answer
Parenting a GameObject with script not working (C#) 0 Answers
c# script not able to set prefab as child of object. 1 Answer
Player exits don't destroy on load because of moving platform 0 Answers