Scripting NPC behavior
- Last UpdatedDec 06, 2023
- 1 minute read
This topic discusses configuring Non Playing Characters.
RobotControl attribute
You can use the robotControl attribute of NPC_name avatar node to script NPC behavior.
-
To change an NPC robotControl script, write down a sequence of actions and then, optionally, put a loop at the end.
-
You can change the robotControl script at any time during runtime, which enables NPC to react to different situations. NPC stops its previous behavior and starts a new script.
-
NPC cannot climb vertical ladders or use normal stairs. It is best to move an NPC on a plane.
Code example
A code example for scripting NPC behavior.
<Command name="moveRobot">
<setfield field="NPC_name.robotControl" value="WALK XV_10150 0.7 #rad(0)# WAIT 5 WALK P_10110A_DIS 0.7 #rad(-90)# WAIT 10 LOOP" />
</Command>