Floating player

I’m making a game where the player floats.

Early test video: Flutuando e movimentando - YouTube

But, I still need it to respect physics and collide with the ground mesh collider.

I added a parent GameObject with a child floating cube to make the camera follow a fixed position instead of the floating cube. Worked OK.

But, when I move the player over a higher ground, it sinks into asphalt (LOL).

I need the floating object middle point to float at an exact altitude over the ground.

How to achieve that?

Thank you.

Use a CharacterController on a GameObject. This will slide along the ground and climb certain angles etc. Pretty useful.

Adjust its collider to be lower or taller than the cube. Place the cube under the CC and only “float” its local position.

Then change your movement code to use CharacterController.Move which respects collision.