fix: make 2d example boid sprite direction accurate
This commit is contained in:
parent
b30b0ef5e4
commit
d33d4e99b8
@ -13,9 +13,8 @@ script/source = "extends Sprite2D
|
|||||||
@onready var boid: Boid2D = get_parent()
|
@onready var boid: Boid2D = get_parent()
|
||||||
|
|
||||||
func _process(delta: float) -> void:
|
func _process(delta: float) -> void:
|
||||||
var dir := boid.get_velocity().normalized()
|
var dir_target := boid.global_position + boid.get_velocity()
|
||||||
var target_rot := atan2(dir.y, dir.x)
|
look_at(dir_target)
|
||||||
rotation = move_toward(rotation, target_rot, delta * PI * 2.0 * absf(target_rot - rotation))
|
|
||||||
"
|
"
|
||||||
|
|
||||||
[node name="ExampleBoid" type="Boid2D"]
|
[node name="ExampleBoid" type="Boid2D"]
|
||||||
|
Loading…
Reference in New Issue
Block a user