Search Unity

  1. Looking for a job or to hire someone for a project? Check out the re-opened job forums.
    Dismiss Notice
  2. Unity 2020 LTS & Unity 2021.1 have been released.
    Dismiss Notice
  3. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

NavMesh ClickToMove Problem

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

  1. TheCasual

    TheCasual

    Joined:
    Sep 30, 2010
    Posts:
    1,289
    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,289
    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 .
     
unityunity