Child object not moving with parent

Hi,

I’m sure im missing something obvious here, however I have trawled through every tutorial and post i can find but cant seem to crack it. Any help would be appreciated.


I have a parent object called “Ship” and a child called “Player”. The end goal is for the ship to be able to move and be effected by physics, while the player can run around on deck.

In my current setup I cant stop the player sliding off the back of the ship when I add force. My understanding is that by making the player a child of the ship it should move with it, however the only way I have found to do this is to make both objects kinematic rigidbodies, which will cause me issues as I want the ship to be affected by physics.


The ship object has a rigidbody attached and I am moving it by adding force (the intent is for this to act like an engine):

void Update()
    {
        //Move the RigidBody forwards at the speed you define
        m_Rigidbody.AddRelativeForce(Vector3.forward * thrust);
    }

The player has a script attached that allows it to move/look around etc. The code for the actual movement is below, (obviously there is supporting code around this). It works fine for a normal FPS style game, however is possibly not the right method for this case.


The player does not have a rigidbody attached.

characterController.SimpleMove(Vector3.ClampMagnitude(fwdMovement + rightMovement, 1f) * _speed);

It’s an old topic, but I just had the same issue. I moved my old project to new unity and new render pipeline system and same script, same player and same platform stopped working.


After checking all the topics with rigidbody, OnTriggerStay, position correction and so on, I found out that there is ‘auto sync transforms’ option which was not enabled in my new project. When I reenabled it, things went back to normal. (Edit → Project Settings → Physics (or Physics 2d) → Auto Sync Transforms

A suggestion that may be worth trying, adding force to both the player and the ship at the same time when the ship moves, though you may have to play around with the amount of force for the player.

When adding force, this should be done in FixedUpdate instead of Update. Anything to do with physics should be executed in FixedUpdate.