NPC Patrol
This component belongs to the following package:
- com.yahaha.sdk.npc
This NPC Patrol Component configures the non-player character's (NPC) patrol behavior.
Property | Description |
---|---|
Is Debug | If enabled, the Component runs in debug mode, providing additional information for testing and troubleshooting purposes in the console. |
Target Tolerance | Sets the distance at which an NPC considers itself arrived at the target position (in meters). Smaller values mean more precise positioning; larger values allow broader acceptance around the target. Minimum value: 0.01. Default value: 0.05. |
Patrol Type | Determines how the NPC will traverse the patrol points or patrol path. It can be set to 'Once' to traverse the points once, 'Loop' to continuously loop through the points, or 'PingPong' to go back and forth between the points. Set to Loop by default.
|
Patrol Path | The patrol path is a collection of points that the NPC will follow during the patrol. Each point represents a specific location or waypoint within the game environment. |
Patrol Point | Sets a specific location within the game environment that the NPC will visit during the patrol. It is represented by a YahahaObject. |
Timeout Seconds | Sets the maximum time allowed for the NPC to reach a patrol point. If the NPC fails to reach the point within the specified time, it will be considered a timeout, and the NPC will attempt to find the next target point. A value less than 0 indicates an unlimited time. Default: -1. |
Speed Multiplier | A multiplier to the NPC's base movement speed during the patrol behavior. A value of 1 represents the normal speed, while values greater than 1 increase the speed, and values less than 1 decrease the speed. Default value: 1. |
Events and Actions
Events
- AlertFromNPCPatrol: Triggered when an anomaly is detected during patrol.
- EventArgs
- Npc: The NPC's behavior.
- EventArgs
- NodeReachedFromNPCPatrol: Triggered when the NPC reaches a patrol point.
- EventArgs
- Npc: The NPC's behavior.
- EventArgs
- TimeOutFromNPCPatrol: Triggered when the patrol times out.
- EventArgs
- Npc: The NPC's behavior.
- EventArgs
- PatrolStart: Triggered when the patrol behavior starts.
- EventArgs
- Npc: The NPC's behavior.
- EventArgs
- PatrolEnd: Triggered when the patrol behavior ends.
- EventArgs
- Npc: The NPC's behavior.
- EventArgs
Conditions
- CheckPatrolPointByIndex: Checks if the current patrol behavior is active.
- Arguments
- npcGameObject: The NPC's YahahaObject.
- index: The ID of the patrol path point, starting from 1.
- Returns: true if the NPC's patrol behavior is active and the currently executed path ID matches the index.
- Arguments
Actions
- ChangeBehaviour: Switches to the patrol behavior.
- Arguments
- npcGameObject: The NPC's GameObject.
- Arguments
- SetEnable: Sets whether the patrol behavior is enabled or not.
- Arguments
- enable: Indicates whether to enable the patrol behavior.
- Arguments