[solved]problem occur when moving to the hit.point

there’s a problem I’ve encoutered:
When I’m standing on the terrain which its surface’s height is really high(like a mountain) and moving to a low height so it like flies to that hit.point and not ‘walks’ to it…

private var speed = 1;
var object : Transform;
var hit : RaycastHit;


var movePosition : Vector3;
var moving : boolean = false;
animation.wrapMode = WrapMode.Loop;


function Update(){
      var ray = Camera.main.ScreenPointToRay (Input.mousePosition);
      if (Physics.Raycast (ray, hit, 3000)  hit.collider.tag == "Terrain"  Input.GetButtonDown("Fire1")) {
        if(moving)
        {
            movePosition = hit.point;
        }else{
            movePosition = hit.point;
            MoveObjectToString();
        }
    }
}
function MoveObjectToString() {
    moving = true;
        while(Vector3.Distance(movePosition, transform.position) > 0.1){
            animation.CrossFade("walk");
            var controller : CharacterController = GetComponent(CharacterController);
            var direction : Vector3 = movePosition - object.position;
            controller.SimpleMove(direction * speed);
            yield;
        }
        animation.CrossFade("idle");
    moving = false;
}

It’s because it’s falling. If you walk down a mountain it’s to steep and far down to walk down the side of it. To do that you would have to force it somehow to stay grounded on the terrain in code. If I am reading you correctly anyway…i’m not sure how to do that tho.

I assume that is what is happening if it works going up but not going down, you only mentioned what happens when going from a high point to a low one.

Solved it :wink: