add new models and rig and handle multiple navigation region
This commit is contained in:
@@ -4,6 +4,7 @@ class_name AIBase
|
||||
|
||||
@export_group("Settings")
|
||||
@export var speed: float = 4.0
|
||||
@export_flags_3d_navigation var navigation_layers: int = 1
|
||||
var _enable_state_machine: bool = true
|
||||
@export var enable_state_machine: bool:
|
||||
set(value):
|
||||
@@ -26,6 +27,8 @@ enum EntityType { HUMANOID, ANIMAL }
|
||||
|
||||
func _ready() -> void:
|
||||
randomize()
|
||||
if nav_agent:
|
||||
nav_agent.navigation_layers = navigation_layers
|
||||
toggle_enable_state_machine()
|
||||
|
||||
func toggle_enable_state_machine() -> void:
|
||||
@@ -67,4 +70,6 @@ func navigate_to_random_point() -> void:
|
||||
if nav_agent.is_target_reachable():
|
||||
return
|
||||
|
||||
nav_agent.target_position = global_position
|
||||
# Fallback: if we can't find a reachable point (e.g. we drifted slightly off navmesh),
|
||||
# try to navigate to the closest navmesh point to our CURRENT position to get unstuck.
|
||||
nav_agent.target_position = NavigationServer3D.map_get_closest_point(nav_map_rid, global_position)
|
||||
|
||||
Reference in New Issue
Block a user