Caracter moving on y axis ?!?

When ever i want to go in front ‘w’ key my caracter start lifting on the Y axis… why ? I tried to add a rigid body to it but then it was spinning on itself… I’m key of new to Unity sorry if this question if stupid :stuck_out_tongue:

var speed = 3.0;
var rotateSpeed : float = 30;
var bullitPrefab: Transform;
private var dead = false;

function OnControllerColliderHit(hit : ControllerColliderHit)
{
if(hit.gameObject.tag == “fallout”)
{
dead = true;
}
}

function Update()
{
var controller : CharacterController = GetComponent(CharacterController);

// Rotate around y - axis
transform.Rotate( 0, Input.GetAxis( “Horizontal”) * rotateSpeed, 0);

// Move forward / backward
var forward = transform.TransformDirection( Vector3.forward );
var curSpeed = speed * Input.GetAxis(“Vertical”);

controller.SimpleMove( forward * curSpeed);

if(Input.GetButtonDown(“Jump”))
{
var bullit = Instantiate(bullitPrefab, GameObject.Find(“Spawn”).transform.position, Quaternion.identity);

bullit.rigidbody.AddForce(transform.forward * 2000);

}
}

function LateUpdate()
{
if(dead)
{
transform.position = Vector3(0 ,4 ,0);
gameObject.Find(“Main Camera”).transform.position = Vector3(0 ,4 ,-5);
dead = false;
}
}

@script RequireComponent(CharacterController);

When using the character controller and rigidbody at the same time weird stuff starts to happen.

So what I would do is go to the rigidbody component of your character and check the boxes that read “freeze position: position x, position y, position z” under the constraints option

I’m not sure if you’re supposed to leave position y unchecked or not so just experiment around a bit.

Hurray for my first time trying to help some one =P.

One more note, I do not think you need a rigidbody to detect collisions, so you can try and remove it if all else fails.