Children affected by a parents movement

I feel like this is a really simple question, but I cannot work out a decent answer.

I have a ‘ship’ made up of various primitives (cube floor, walls) in a hierarchy that looks like this:

Ship (empty gameobject)
----Room (empty gameobject)
--------Wall (primitive cube)
--------Wall
--------Wall
--------Wall
--------Floor (primitive cube)
----Room
--------etc
--------etc

In the rooms the player can move around, the player currently being a cube with a texture on it. The player has a rigidbody.

Also in the rooms are cubes (cargo) with rigidbodies.

Everything works fine until I move the top level Ship using Translate. I had expected the player and the cargo to also move with the parent, however because of the rigidbodies they are also affected somewhat by physics and move toward the back of the ship.

How can I fix them so they ignore the parent movement but still react to physics events from other objects? It feels like there should be a simple answer I’m just missing due to deficient sleep.

I don’t really know the reason or solution for this but you can talk to the Super Moderator of this forums about it.

Hi,

I have a suspicion it has to do with the ridid bodies I’ve added to the player and the boxes that are inside the ship. To be honest I’m not sure I need physics for these objects as in the long run I envisioned them being fixed in place anyway.

After some thought overnight I’ve decided to remove the rigid body components, add a character collider to the player object and use primitive colliders for everything else (for now).

The ultimate goal is to have a custom built ship made up of various rooms and components that can be flown through (currently 2D) space while at the same time the player can move around the ship and interact with ship components and AI. Hence, I need a parent gameobject (the ship) to move and move all it’s children (rooms and their contents) but not affect any other game objects inside the rooms when the ship moves.

I just wanted to pop back to add my solution just in case another novice (like me) has a similar problem.

The issue with having child objects in a moving parent AND giving them rigidbody components to assist with collision detection is that they are also affected by the physics of the parents movement. While this is correct, and cool to play with (I had a ship flying about, making all the loose cargo slide around while the player also slid around - caused by the parent’s movement), it’s not a great game mechanism.

To solve this and have the cargo and the player NOT slide all over the place, I removed the rigidbody component from the cargo boxes and the player and added a Character Controller to the player. After a little re-scripting (and around 2 hours work) everything was back to normal and I could fly a ship through space while simultaneously walking my player character through the ships rooms. Pretty pleased with that outcome.

I found that if I increased the ships speed above ~20m/s, strange collision detection failures would begin cropping up and my animated sliding doors would not trigger properly (not working, opening and shutting multiple times). That’s a problem for another time though…