3d enemy movement

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Ogeeice

I have the idea of an enemy that moves in a location wuthout leaving the area,the only problem is implimenting this

:bust_in_silhouette: Reply From: Magso

You can connect the body_exited signal and give the enemy a behaviour or use the navigation nodes by baking a closed off navigation mesh.

I thought the nav mesh was used in path finding how would that serve my purpose

Ogeeice | 2019-07-05 15:55

What kind of enemy movement are you trying to achieve?

You can use navigation node with navmeshes to achieve movement within an area.
I haven’t worked with baked navmeshes, but I have used navigation and navmeshes in one of my projects (available on Github), to achieve enemy movement to chase a player (if within a set distance), or use waypoints to move around the nav area.

Navigation related nodes are for pathfinding, but because pathfinding only takes place with their bounds, they can prevent units leaving an area.

DamonR | 2019-07-05 19:00

Can you tell me how to set up the navmesh YouTube videos don’t really make it easy to understand

Ogeeice | 2019-07-05 21:57

I’ve never used the navigation node myself but from what I know both navigation node and a navigationMeshInstance as a child are needed. Make the ground meshInstance a child of navigationMeshInstance, select the navigationMeshInstance and click bake at the top of the scene tab.
The enemy needs to be a kinematicbody and in it’s script, reference the navigationMeshInstance and use get_simple_path(startPoint, endPoint) to get an array of vector3s for the path and move the kinematicbody using move_and_slide. get_simple_path() will need to be updated very frequently if the enemy is following the player. Hopefully someone can explain it better than this.

Magso | 2019-07-05 22:59

GitHub - DamonRaziel/NavigationDemo

This is a quickly made stripped down version of the code and nodes I used in my main demo game (learning how to do things in Godot, main project is GitHub - DamonRaziel/Project-Bob-s-Quest: Project Bob's Quest was built to test my abilities and see what I could learn. It is still a work in progress, and can be used as a base for various mechanics.), so it may not be perfect, but it works. I reversed it from the navmesh demo. Hope it helps.

DamonR | 2019-07-05 23:45