Преглед изворни кода

:wrench: Make the chicken stops when hit

Start running after a second.
DricomDragon пре 2 година
родитељ
комит
e583c2c5e0

+ 9 - 2
godot/component/entity/chick/Chicken.gd

@@ -23,8 +23,8 @@ func attack(from: Vector2, angle: float):
 	_current_state = State.WALKING
 
 
-func _physics_process(delta):
-	var collision = move_and_collide(velocity * delta, false)
+func _physics_process(delta: float):
+	var collision = _move(delta)
 	_collide_and_react(collision)
 
 
@@ -45,6 +45,13 @@ func _die():
 	queue_free()
 
 
+func _move(delta: float) -> KinematicCollision2D:
+	if _current_state == State.WALKING or _current_state == State.RUNNING:
+		return move_and_collide(velocity * delta, false)
+	else:
+		return move_and_collide(Vector2.ZERO, false)
+
+
 func _collide_and_react(collision: KinematicCollision2D) -> void:
 	if collision == null:
 		return

+ 1 - 0
godot/component/entity/spawner/MobSpawner.tscn

@@ -20,4 +20,5 @@ process_mode = 0
 wait_time = 0.53
 
 [node name="MobSpawnLocation" type="PathFollow2D" parent="."]
+
 [connection signal="timeout" from="MobTimer" to="." method="_on_MobTimer_timeout"]