Selaa lähdekoodia

:beetle: Fix chicken jitter

Chicken was blinking when collideng up / down.
DricomDragon 2 vuotta sitten
vanhempi
commit
51fb7c757e
1 muutettua tiedostoa jossa 5 lisäystä ja 1 poistoa
  1. 5 1
      godot/component/entity/chick/Chicken.gd

+ 5 - 1
godot/component/entity/chick/Chicken.gd

@@ -60,7 +60,7 @@ func _collide_and_react(collision: KinematicCollision2D) -> void:
 	if collider is Node2D:
 		var node_collider = collider as Node
 		if _current_state == State.WALKING:
-			if node_collider.is_in_group("chicken"):
+			if node_collider.is_in_group("chicken") and _facing_collider(collision.get_normal()):
 				_turn_away()
 			elif node_collider.is_in_group("wheel"):
 				_get_angry()
@@ -90,5 +90,9 @@ func _start_running() -> void:
 	_current_state = State.RUNNING
 
 
+func _facing_collider(normal: Vector2) -> bool:
+	return normal.x * velocity.normalized().x < -0.5
+
+
 func _update_sprite_direction() -> void:
 	$AnimatedSprite.flip_h = velocity.x < 0.0