godot_boids/examples/boids/2d/example_boid.tscn

27 lines
870 B
Plaintext
Raw Normal View History

2024-08-29 04:51:21 +03:00
[gd_scene load_steps=4 format=3 uid="uid://b2sg3n42rkbx8"]
[ext_resource type="Texture2D" uid="uid://rk5u1wthr0n0" path="res://examples/boids/2d/example_boid.svg" id="2_jx2vb"]
2024-08-29 04:51:21 +03:00
[sub_resource type="BoidProperties" id="BoidProperties_a6wou"]
2024-08-30 01:32:01 +03:00
alignment = 1.0
cohesion = 0.8
[sub_resource type="GDScript" id="GDScript_ldfpo"]
resource_name = "example_boid_sprite"
script/source = "extends Sprite2D
@onready var boid: Boid2D = get_parent()
func _process(delta: float) -> void:
2024-08-29 04:51:21 +03:00
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))
"
2024-08-29 04:51:21 +03:00
[node name="ExampleBoid" type="Boid2D"]
properties = SubResource("BoidProperties_a6wou")
[node name="Sprite2D" type="Sprite2D" parent="."]
texture = ExtResource("2_jx2vb")
script = SubResource("GDScript_ldfpo")