0
\$\begingroup\$

Here is my code for spawning the jaw of one of my enemies. It is set to a child of the main enemy as I'm controlling the animations separately for different parts of the enemy:

void Awake()
{
    jaw = (GameObject)Instantiate(jaw, transform.position + jawOffset, transform.rotation);
    jaw.transform.SetParent(transform, true);
}

This works, and sets the jaw as a child to the main enemy body, but the child doesn't follow the movement of the parent.

I'm using gravity to have the parent body slowly fall down the screen, and the jaw simply stays in it's originally instantiated position. I'd like the jaw to stay in the same position it was spawned relative to the parent, so fall at the same rate.

\$\endgroup\$
1
  • \$\begingroup\$ Does the jaw have a Rigidbody component, or a script that's setting its transform.position regularly? Those two can possibly break parent-relative movement, which will otherwise "just work" exactly as you describe. \$\endgroup\$
    – DMGregory
    Dec 21 '21 at 19:55

You must log in to answer this question.

Browse other questions tagged .