Character collision of walls inside moving ship

Ok, finally admit I’m stuck.

Here’s what I’m trying to do. I have a space ship, constructed of individual (child) parts each with different colliders contributing to the rigidbody of the (parent) space ship. I’m adding relative torque and force to the rigidbody of the (parent) ship to make it and all its parts move through space. In a different game state the player has a first person character that can move around the ship. I need to make this character maintain the movements of the ship, while being able to move independently around the ship and colliding with its walls, stopping it from moving outside of the ship and also allowing it to slide down the wall as you would in a typical FPS. Consider this an artificial gravity / inertial dampener type setup.

Character controller doesn’t work since it is only good at rotating around the y axis. Rigidbody won’t act like a child of the (parent) ship, and I’ve read that its not good to have a child rigidbody of a parent rigidbody. I’ve tried the custom rigidbody joint but I can’t figure out what I’m doing with it.

The closest I’ve come is having no rigidbody or character controller, parenting the FPS character to the ship and moving the transform around manually, doing a CapsuleCastAll to try and figure out the collision and alter the movement, but it turns out I’m more math stupid than I thought I was.

Can anyone think of trick of the system I can use to stay within PhyisX functionality or can you point me to a manual collison / character movement script I might be able to reference for this scenerio?

Thanks in advance!

I’ve thought of a second different approach.

Just make a second fake ship that is stationary (SFSTIS) and sit it stationary off stage. Put the guy inside the SFSTIS. Again, your ACTUAL guy only goes INSIDE the SFSTIS.

Let the guy walk around in the SFSTIS - the SFSTIS has real ordinary gravity physics and so on, just like on the surface of the normal Earth. Everything happens in there in the SFSTIS.

Now – simply PUPPET thet guy on the SFSTIS, TO a doppleganger guy - a puppet - inside the on-camera ship that is being tossed around.

To be clear, put your main camera IN the main ship (there’s NO CAMERA in the SFSTIS). Your camera on the main ship is looking at the doppleganger on that main ship. That’s the only thing the human end-player sees or knows about.

BUT “he” (actually just the doppleganger) will be walking around totally normally, apparently completely unaffected by the crazed gyrations of the main ship. You will see all the tossing, etc, action out the windows because your camera is indeed there in the main ship. The camera is actually only looking at a doppleganger guy - the REAL guy is on the SFSTIS.

Voila.

(This solution is sort of like using a motion capture studio, in realtime, inside Unity :slight_smile: ) Hope it helps!


FTR here is the older answer … the other way around.

// Hell – could you have … a FAKE UNIVERSE and a REAL UNIVERSE.

// In your REAL UNIVERSE, the ship for example gets tossed left, and then right.

// So what happens in the fake universe? In the FAKE universe, EVERYTHING IS KINEMATIC.

// In the FAKE universe you EXACTLY DUPLICATE EVERYTHING from the real universe, from moment to moment, but there’s no physics. (This is easy to do with two lines of code. Every frame, just match the position and rotation of every item.)

// Now in the FAKE universe, always utterly rotate the entire fake universe so that every frame the ship is always sitting still in the middle in center frame. - ET VOILA

// have your guy, and the actual game cam, inside the ship in the fake universe. Every single thing seen out the windows would be identical to the scene in the real universe, but, the ship would apparently be at rest and flat.