Point & click to move and working with Nav mesh for smart AI in Unity

  • Select the Bake tab and press the Bake button at bottom-right
  • Create a new script, call it Player and attach it to the player game object
  • To move the player towards a position pointed out with a click, we will need to check if it was a left click. If so, cast a ray from that position.
  • After a ray is created, we can access the info about the game object that has been hit by first, creating a variable of type RayCastHit that can be called hitInfo and later checking out if there was any game object hit with Physics.Raycast boolean
  • Select the objects game object (which contains all the boxes) and mark it as static
  • Open the navigation tab, click on Clear and later on Bake

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store