The problem is that when my character hits a mountain on my terrain he falls through the map. I think I know what is happening but I am not sure how to fix it. Its like the controls are not working with the character controller and the slope limit value is completely ignored. I know I am a n00b but all my 3d models are going to wast and I have no programmer. Here is my code…
var speed = 80.0;
var gravity = 20.0;
private var x : float;
private var z : float;
private var moveDirection = Vector3.zero;
function FixedUpdate (){
var controller : CharacterController = GetComponent(CharacterController);
// x is used for the x axis. set it to zero so it doesn't automatically rotate
//x = 0;
if(controller.isGrounded){
x = Input.GetAxis("Horizontal") * Time.deltaTime * speed;
// transform.Translate(x, 0, 0);
transform.Translate(x, 0, 0, Space.World);
// check to see if the W or S key is being pressed.
z = Input.GetAxis("Vertical") * Time.deltaTime * speed;
// Move the character forwards or backwards
transform.Translate(0, 0, z, Space.World);
//transform.Translate(0, 0, z);
}
moveDirection.y -= gravity * Time.deltaTime;
controller.Move(moveDirection * Time.deltaTime);
}
// Check to see if the A or S key are being pressed
//if (Input.GetAxis("Horizontal"))
// {
// Get the A or S key (-1 or 1)
// x = Input.GetAxis("Horizontal");
// }
// Check to see if the right mouse button is pressed
// if (Input.GetMouseButton(1))
// {
// Get the difference in horizontal mouse movement
// x = Input.GetAxis("Mouse X") * turnSpeed * mouseTurnMultiplier;
// }
// rotate the character based on the x value
// transform.Rotate(0, x, 0);
//}