add gamestate, doc and fix
This commit is contained in:
@@ -9,9 +9,9 @@ class_name AIBase
|
||||
toggle_enable_state_machine()
|
||||
|
||||
|
||||
@onready var patrol_radius_shape: CollisionShape3D = $PatrolRadiusShape
|
||||
@onready var nav_agent: NavigationAgent3D = $NavigationAgent3D
|
||||
@onready var state_machine: StateMachine = $StateMachine
|
||||
@onready var patrol_radius_shape: CollisionShape3D = $%PatrolRadiusShape
|
||||
@onready var nav_agent: NavigationAgent3D = $%NavigationAgent3D
|
||||
@onready var state_machine: StateMachine = $%StateMachine
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
@@ -19,7 +19,7 @@ func _ready() -> void:
|
||||
toggle_enable_state_machine()
|
||||
|
||||
func toggle_enable_state_machine() -> void:
|
||||
$StateMachine.enable = enable_state_machine
|
||||
state_machine.enable = enable_state_machine
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
if !enable_state_machine:
|
||||
|
||||
@@ -22,8 +22,10 @@ mesh = SubResource("CapsuleMesh_mh3lg")
|
||||
shape = SubResource("CapsuleShape3D_mh3lg")
|
||||
|
||||
[node name="NavigationAgent3D" type="NavigationAgent3D" parent="." unique_id=1370024449]
|
||||
unique_name_in_owner = true
|
||||
|
||||
[node name="StateMachine" type="Node" parent="." unique_id=1286404264 node_paths=PackedStringArray("initial_state")]
|
||||
unique_name_in_owner = true
|
||||
script = ExtResource("2_q1hg3")
|
||||
initial_state = NodePath("IdleState")
|
||||
|
||||
@@ -36,6 +38,7 @@ script = ExtResource("4_lim44")
|
||||
state_id = "patrol"
|
||||
|
||||
[node name="PatrolRadiusShape" type="CollisionShape3D" parent="." unique_id=1379515938]
|
||||
unique_name_in_owner = true
|
||||
shape = SubResource("SphereShape3D_lim44")
|
||||
disabled = true
|
||||
debug_color = Color(1, 1, 0, 1)
|
||||
|
||||
@@ -44,5 +44,3 @@ func _on_state_transition(state: State, new_state_id: String) -> void:
|
||||
|
||||
current_state = new_state
|
||||
current_state.enter()
|
||||
|
||||
print("Transizione a: ", current_state.state_id)
|
||||
|
||||
Reference in New Issue
Block a user