How to get collisions working on a flying controller?

I have a section in my game where the player enters a maze, colliding with a trigger that essentially disables gravity. They can then fly around in the maze. I am using the FPS Character Controller.

The problem is, the player no longer collides with anything. I’ve put a rigidbody on the controller, but no good.

The trigger disables the “Character Motor” script, the “MouseLook” on the Controller, and the “MouseLook” on the camera. The following code is then enabled, enabling free flight:

var turnSpeed = 10.0;
var moveSpeed = 10.0;
var mouseTurnMultiplier = 1;

private var x : float;
private var z : float;
function Update () 
    // x is used for the x axis.  set it to zero so it doesn't automatically rotate
    //x = 0;

    // check to see if the W or S key is being pressed.  
    z = Input.GetAxis("Vertical") * Time.deltaTime * moveSpeed * 10;

    // Move the character forwards or backwards
    transform.Translate(x, 0, z);////

    zx = Input.GetAxis("Horizontal") * Time.deltaTime * moveSpeed * 10;

    // Move the character forwards or backwards
   transform.Translate(zx, 0, 0);  ////

    // Get the difference in horizontal mouse movement
    x = Input.GetAxis("Mouse X") * turnSpeed * mouseTurnMultiplier/10;
    y = Input.GetAxis("Mouse Y") * turnSpeed * mouseTurnMultiplier/10;

    // rotate the character based on the x value
    transform.Rotate(-y, x, 0);   //transform.Rotate(-y, x, 0); <<<


So I can then fly around fine, but don’t collide with anything.

I’ve been trying to figure this out for two days. I’ve read every single scrap of information I can on Answers etc. but I’m just not able to get it to work.

If I fly to a point within the maze, and then switch the Mouselooks and Controller back on, and the above script off, gravity re-engages, the character falls, and collisions are back to normal.

Any ideas? This is making me feel really stupid and I’m sure it can’t possibly be that complicated…

Thanks in advance :wink:

Ive actually solved this problem

Like GC said dont use translate because that ignores collision
whenever you wish to create movements that respect collisions:
use either charactercontroller.move or the rigidbody move system.
rigidbody is good because it will allow you to have very physics grounded motions.

however there are problems:
if you use rigidbody motion it requires a solid collider to handle its collisions. If you have both a character controller movement script and a rigidbody movement system. The character controller will fight with whatever solid collider you have and cause obnoxious problems. In my own script I am dealing with this by disabling everything used for the controller system when i switch to my flight system.

Now I dont know what you mean by flight in regards to a maze.
but when doing mine
I found this to be an AWESOME starting point to which i modded the hell out of: