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

35 lines
1.1 KiB
Plaintext
Raw Normal View History

[gd_scene load_steps=6 format=3 uid="uid://b2sg3n42rkbx8"]
[ext_resource type="Script" path="res://addons/boids/boid_2d/boid_2d.gd" id="1_vh1uc"]
[ext_resource type="Texture2D" uid="uid://rk5u1wthr0n0" path="res://examples/boids/2d/example_boid.svg" id="2_jx2vb"]
[ext_resource type="Script" path="res://addons/boids/boid_properties/boid_properties.gd" id="2_up2nk"]
[sub_resource type="Resource" id="Resource_m74bv"]
script = ExtResource("2_up2nk")
max_speed = 4.0
max_force = 1.0
alignment = 1.5
cohesion = 1.0
seperation = 1.2
targeting = 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:
var dir := boid.velocity.normalized()
var target_rot := atan2(dir.y, dir.x)
rotation = move_toward(rotation, target_rot, delta * PI * 2.0 * absf(target_rot - rotation))
"
[node name="ExampleBoid" type="Node2D"]
script = ExtResource("1_vh1uc")
properties = SubResource("Resource_m74bv")
[node name="Sprite2D" type="Sprite2D" parent="."]
texture = ExtResource("2_jx2vb")
script = SubResource("GDScript_ldfpo")