Walking On Walls and Ceilings

Hi guys, I'm trying to create an FPS where the player will be able to walk on the walls and ceiling, as well the floor, of the inside of a cube.

The player would access these other surfaces by using sections of curved wall that connect the floors to walls and walls to ceiling.

Put basically, I need know how to stick the bottom of a movable First Person Controller to walls 90 degrees to the floor and the ceiling 180 degrees to the floor.

Any ideas on a technique that would enable me to achieve this would be greatly appreciated.

Many thanks, Will.

While I'm not sure that you could get the first person controller to do that (I don't have doubts I just don't know) you could do it pretty easily with a rigidbody, collider, custom controller setup that figures out it's own gravity.

Since you're using a cube and not a spheroid you could probably get away with using triggers. Basically you'd want to make a big trigger for each area of differing gravity. Using the onCollisionEnter and onCollisionStay functions you could just rotate the player so that 'down' is the right direction. If you build your controller where gravity is always down relative to the player/enemy/random object in its local coordinate space all you'd have to do is a simple rotation onCollisionEnter.

For rounded surfaces you could try casting a ray down from the player then setting the player's rotation such that the player's 'up' vector lines up with the normal of the surface that the ray hit.

If you're dealing with spheriods you wouldn't need any of that, you'd just need to rotate 'down' so that it's pointing at the spheroid's center, or away if you want to be inside the object.

Hope that helps :) Good luck.

the locomotion example might help you with this its 3rd person though with the character going around a planet you propply be able to adapt that

Thanks for the tip Andy, I'll look into it.