I have a movement script that using a character controller connected to my character and I am having trouble with gravity, jumping and momentum from isGrounded being off and being in the air.
I use the following script
var speed = 4.50;
var jumpSpeed = 8.00;
var gravity = 20.00;
function Update(){
var controller : CharacterController = GetComponent(CharacterController);
if (controller.isGrounded) {
moveDirection = Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical"));
moveDirection = transform.TransformDirection(moveDirection);
moveDirection *= speed;
if (Input.GetButtonDown("Jump")) {
moveDirection.y = jumpSpeed;
}
}
// Apply gravity
moveDirection.y -= gravity * Time.deltaTime;
// Move the controller
controller.Move(moveDirection * Time.deltaTime);
}
Gravity - It seems to slowly float to the ground instead of just dropping like normal. How do I fix this?
Jumping - My character just suddenly appears up in the air just above were he was; How would I make this a gradual move up and down smooth instead of just appearing?
Momentum - When I am jumping or walking off a ledge I notice that I just drop straigt down instead of continuing forward awhile from momentum you would have normally had in real life. How do I make it have that momentum effect?