Search Unity

NavMesh ClickToMove Problem

Discussion in 'Editor & General Support' started by TheCasual, Apr 2, 2012.

  1. TheCasual

    TheCasual

    Joined:
    Sep 30, 2010
    Posts:
    1,286
    SOLVED : IGNORE THIS


    Seems that transform.LookAt data is no longer required with nav mesh , and i had the camera parented to the character which was causing an unwanted effect. All works great now. Spectacular feature Unity.



    Hello everyone. I am just trying out navMesh for the first time, and i am pretty amazed again by Unity , but im having one slight problem understanding an issue i have with traversing a simple test terrain (geometery) i have created.



    now , when running around the scene , and holding the mouse button down, the pointToMove to is accurately updating , and the character moves around as expected, but... when trying to navigate up the stairs and still constantly holding the mouse button down, the character seems to be *pushed* backwards almost., and only proceeds to climb the stairs when the button is let go.

    Does anyone have any ideas , insight as to what the problem may be. Could even be the script im thinking, as i said , very simple just to get a quick test in and see how it all works. Heres the script too.


    Code (csharp):
    1. #pragma strict
    2.  
    3. var speed : float;
    4. var pointClicked : Vector3;
    5. var isMoving : boolean = false;
    6. var characterController : CharacterController;
    7.  
    8. function Start(){
    9.     characterController = GetComponent(CharacterController);
    10. }
    11.  
    12. function FixedUpdate(){
    13.    
    14.     var ray : Ray;
    15.     var hit : RaycastHit;
    16.     ray = Camera.main.ScreenPointToRay(Input.mousePosition);
    17.    
    18.     if(Input.GetMouseButton(0)){   
    19.         if(Physics.Raycast(ray.origin, ray.direction, hit, 1000)){
    20.             if(hit.collider.tag == "Walkable"){
    21.                 pointClicked = hit.point;
    22.                 transform.LookAt(hit.point);
    23.                 GetComponent(NavMeshAgent).destination = hit.point;
    24.                 isMoving = true;
    25.             }
    26.         }
    27.     }
    28.     if((transform.position - pointClicked).magnitude < 1)
    29.         isMoving = false;
    30.     if(isMoving == true){
    31.         animation.CrossFade("MinoRun");
    32.     }
    33.     else{
    34.         animation.CrossFade("MinoIdle");
    35.     }
    36. }
     
    Last edited: Apr 2, 2012
  2. TheCasual

    TheCasual

    Joined:
    Sep 30, 2010
    Posts:
    1,286
    SOLVED ... (closing the nav mesh window does this ... sob , but i like 15 windows open at one time.) however one last question about nav mesh....

    how do you turn off the blue mesh tint in the scene view?

    haha o_O thanks .