Page:
Navigation
Pages
Animation
Asset browser
Audio
Available plugins
Basis Universal
Building 3rd party libraries
Case sensitive filesystems
Code rules
Command line
Custom plugin
Exporting game
Features
Filesystem
Getting started
Home
Hot reload
How to move from Unity to Lumix
Importing assets
Ingame GUI
Knowledge base
Latency
List of free assets
Lua scripting
Native Scripting
Navigation
Particle system
Physics
Plugin hotreload
Profiler
Resource UID
Terrain
Video tutorials
Writing a postprocess effect
4
Navigation
Mikulas Florek edited this page 2021-03-13 13:01:27 +01:00
Table of Contents
There are several ways to do navigation depending on whether animation or physics is involved. Zones are related to all of them.
Zones
- 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
No animation, no physics
- 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.
Animation and physics
- 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);