- Home /
Enemy doesn't avoid static objects
I am currently working on a tanks game, every works fine in the enemy ai but I don't know how to script the nav mesh in order to get the enemy tanks to avoid static environmental objects. I'm mostly a modeller/animator so I'm new to scripting
Answer by C_R_E_A_T_R_O_R · Aug 02, 2018 at 12:13 PM
Hey, you dont have to script the nav mesh. All you have to do is set the objects that wont move during playmode, to static, and then bake your nav mesh from the navigation tab. Your tank should now recognize and avoid your environmental objects.
Answer by JVLVince · Aug 02, 2018 at 12:20 PM
Take a look here. I'm pretty sure this is what you want. You do not need to implement any code unless you want to custom your character (tank) behavior. If you have any problem just mess me. :D
https://docs.unity3d.com/Manual/class-NavMeshObstacle.html
Sometimes you will face with the "push" out other tank behavior when you faced that case, take a look here, the avoidance priority
https://docs.unity3d.com/Manual/class-NavMeshAgent.html
Hope this help, cheers!!!