-
Notifications
You must be signed in to change notification settings - Fork 398
Navigation
Mikulas Florek edited this page Mar 13, 2021
·
4 revisions
There are several ways to do navigation depending on whether animation or physics is involved. Zones are related to all of them.
- create an entity
- add
navigation / zone
component - set desired size
- click
generate
in property grid - click
save
in property grid to save the recently generated navmesh data
You can check Draw navmesh
in property grid to make sure your navmesh is correct
- creat an entity, the entity must be inside
navigation zone
- add
navigation / agent
component - add
lua script
component - call
this.navmesh_agent:navigate(destination, 10, 1)
in agent's script
You can see demo as an example.
- creat an entity, the entity must be inside
navigation zone
- add
navigation / agent
component - uncheck
Move entity
, so navmesh agent won't try to move entity directly - add
physics / controller
component - check
use root motion
, controller will try to get root motion for animation system and apply it - add
animation / animator
component and set some graph with root motion to it - in code, you have to get speed and angle from navigation system and set it to animation system, for example like this:
float speed = m_navigation_scene->getAgentSpeed(e);
float dir = -m_navigation_scene->getAgentYawDiff(e);
const i32 dir_idx = m_ani_scene->getAnimatorInputIndex(e, "dir");
const i32 speed_idx = m_ani_scene->getAnimatorInputIndex(e, "speed");
m_ani_scene->setAnimatorInput(e, dir_idx, dir);
m_ani_scene->setAnimatorInput(e, speed_idx, speed);