- Home /
hazard Ai patroling with navMesh.
Instead of making waypoint to a ai, is there a way to use the navmeshsysteme of unity to make you're ai travel on the levels hazardly ? and when he detect the player he attacks you.
(like the ai of the alien in alien insolation.)
Answer by HarshadK · Jan 06, 2015 at 09:03 AM
You can use NavMesh to create the AI you require. Just provide any random position to your AI to move to and when he reaches that position assign a new position for your AI to move to. Just rinse and repeat. If while moving, AI spots the player make him move towards the player.
Use NavMeshAgent.PathStatus to check if the AI has reached destination or not and assign him a new position to move to using NavMeshAgent.SetDestination.
Read through the NavMeshAgent scripting info to find any more details on available variable and methods.
i will try to come up with a script but thank you for showing me where to go. =)
how do we make new position in scripts with the navmeshes? (sorry mite be a newbe question but still learning and curious ).
Just choose any position that falls between the area of your world and assign it to the Nav$$anonymous$$eshAgent as destination.
Answer by Kiwasi · Jan 07, 2015 at 01:42 AM
You want to investigate navmesh layers and costs. In short you assign high costs to the more hazardous areas, and the navmesh agent will avoid them.
Your answer
Follow this Question
Related Questions
npc patrol and chase 1 Answer
How to remove z axis control from script 1 Answer
Enemy patrol is not working in AI Behavior plugin 0 Answers
Monster Patrolling 1 Answer
Make AI move using CharacterController.Move instead of rigidbody.velocity? 3 Answers