From d33d4e99b839252988c372a1fb7e82d187cef74b Mon Sep 17 00:00:00 2001 From: dusk Date: Fri, 6 Dec 2024 23:06:15 +0300 Subject: [PATCH] fix: make 2d example boid sprite direction accurate --- examples/boids/2d/example_boid.tscn | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/examples/boids/2d/example_boid.tscn b/examples/boids/2d/example_boid.tscn index d97cd89..0f8f027 100644 --- a/examples/boids/2d/example_boid.tscn +++ b/examples/boids/2d/example_boid.tscn @@ -13,9 +13,8 @@ script/source = "extends Sprite2D @onready var boid: Boid2D = get_parent() func _process(delta: float) -> void: - var dir := boid.get_velocity().normalized() - var target_rot := atan2(dir.y, dir.x) - rotation = move_toward(rotation, target_rot, delta * PI * 2.0 * absf(target_rot - rotation)) + var dir_target := boid.global_position + boid.get_velocity() + look_at(dir_target) " [node name="ExampleBoid" type="Boid2D"]