Custom Gravity CharacterController

I am working on a project in which we have a character moving around an Escher like space. The game is first person and the default character controller is actually almost perfect. The issue is that we need to change the orientation of the avatar so that it would be walking around the on the wall or the ceiling.

Currently we are rotating the entire environment and leaving the avatar orientation the same. This is causing issues with Unity’s static batching, so we are again trying to figure out a way to rotate the player.

Question 1:
Can anyone suggest an easy way to script around the default CharacterController so that we can change the direction of gravity?

Failing that I am looking for a good/free-to-use character controller script which I might modify rather than writing one from scratch. I found this one:

RigidbodyFPSWalker

but it is really glitchy and we don’t actually want a physics based controller.

Question 2:
Can anyone suggest a character controller script that simply duplicates the built in CharacterController? (Bonus points for JS but CS will also be fine)

----------------- EDIT -----------------

Getting global gravity to change is fairly easy. I am looking for a way to rotate the character controller So that the camera orientation and the movement will match the changed gravity.

I am having the same problem. From what I can see the “gravity” direction seems to be hard coded within the character controller itself. I’m currently trying to re-create its functionality as a rigidbody controller, but if there is a way to get the character controller to use a custom vertical direction, I’d be happy to know.

You can edit unity gravity using:

Physics.gravity = Vector3(0, -1.0, 0);

To change directions you can set x, y or z to a value - the vector function looks like this:

Vector3(x, y, z);

So if you set gravity to:

Physics.gravity = Vector3(-1.0, 0, 0);

Then the character etc will fall to the left or right.

Here’s the unity documentation: http://unity3d.com/support/documentation/ScriptReference/Physics-gravity.html

I’d advise to always check there :wink: