Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Click to move - 8 axis

Discussion in 'Navigation' started by henmachuca, Jan 26, 2017.

  1. henmachuca

    henmachuca

    Joined:
    Oct 14, 2016
    Posts:
    105
    Hello,

    I would like to know if anyone knows how to achieve a click to move movement restricted to 8 axis.

    I'm trying to do this to achieve a more old school rpg look to my game.
    I'm currently using NavMeshAgent to do the movement, pretty straight forward, but don't know how to achieve the result I want now.

    Any ideas??

    Thank you!
     
  2. IvanDonets

    IvanDonets

    Joined:
    Feb 19, 2014
    Posts:
    117
    Click to move seems to be simple when you only need to move to destination, but gets harder when you click on enemy and player should approach enemy first and then only attack.
    https://docs.unity3d.com/Manual/nav-MoveToClickPoint.html
    Physics.Raycast 'sends' ray to clicked point by mouse, but not sure how that works when a few gameobjects are "caught" by same ray (there is "foreach (RaycastHit hit in hits)" solution)

    you can try my RPG project, it has click-tomove more or less done:
    https://github.com/ivandonetsunity3d/Kshatriya3d

    (not sure about 8 axis, though)