mirror of
https://github.com/Steffo99/hella-farm.git
synced 2024-11-24 17:14:23 +00:00
Add Watcher
movement
This commit is contained in:
parent
d672c94d78
commit
af1cb67796
3 changed files with 63 additions and 1 deletions
34
behaviours/move_tilt.gd
Normal file
34
behaviours/move_tilt.gd
Normal file
|
@ -0,0 +1,34 @@
|
|||
extends MoveStraight
|
||||
class_name MoveTilt
|
||||
|
||||
|
||||
## A [Move] which moves in a direction, rotating by a bit each frame.
|
||||
|
||||
|
||||
## Speed at which the direction changes per second, in degrees per second.
|
||||
@export var rotation_speed: float = 0.0
|
||||
|
||||
## The minimum [field rotation_speed] that will be set.
|
||||
@export var min_rotation_speed: float = 0.0
|
||||
|
||||
## The maximum [field rotation_speed] that will be set.
|
||||
@export var max_rotation_speed: float = 0.0
|
||||
|
||||
|
||||
func set_rotation_speed(value: float) -> void:
|
||||
rotation_speed = value
|
||||
|
||||
func set_rotation_speed_to_min() -> void:
|
||||
rotation_speed = min_rotation_speed
|
||||
|
||||
func set_rotation_speed_to_max() -> void:
|
||||
rotation_speed = max_rotation_speed
|
||||
|
||||
func randomize_rotation_speed() -> void:
|
||||
rotation_speed = Random.rng.randf_range(min_rotation_speed, max_rotation_speed)
|
||||
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
if enabled:
|
||||
move.emit(direction * delta * speed)
|
||||
direction = direction.rotated(deg_to_rad(delta * rotation_speed))
|
6
behaviours/move_tilt.tscn
Normal file
6
behaviours/move_tilt.tscn
Normal file
|
@ -0,0 +1,6 @@
|
|||
[gd_scene load_steps=2 format=3 uid="uid://ca02sfyaislwu"]
|
||||
|
||||
[ext_resource type="Script" path="res://behaviours/move_tilt.gd" id="1_t0qjp"]
|
||||
|
||||
[node name="MoveTilt" type="Node2D"]
|
||||
script = ExtResource("1_t0qjp")
|
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=24 format=3 uid="uid://dnjtduk0hla3f"]
|
||||
[gd_scene load_steps=26 format=3 uid="uid://dnjtduk0hla3f"]
|
||||
|
||||
[ext_resource type="Script" path="res://entities/watcher.gd" id="1_brahc"]
|
||||
[ext_resource type="PackedScene" uid="uid://bxbjfev0lhwws" path="res://behaviours/sprite_left_right.tscn" id="1_thu73"]
|
||||
|
@ -10,7 +10,9 @@
|
|||
[ext_resource type="Texture2D" uid="uid://b6uurud5clnqr" path="res://entities/watcher_drag_right.png" id="8_5nq2n"]
|
||||
[ext_resource type="PackedScene" uid="uid://rx24bppccih7" path="res://behaviours/move_physics.tscn" id="8_jy8ay"]
|
||||
[ext_resource type="PackedScene" uid="uid://cm67ko1k6kn4u" path="res://behaviours/priority.tscn" id="9_wtsor"]
|
||||
[ext_resource type="PackedScene" uid="uid://ca02sfyaislwu" path="res://behaviours/move_tilt.tscn" id="9_xig8d"]
|
||||
[ext_resource type="PackedScene" uid="uid://dijcjahkddudv" path="res://behaviours/draggable.tscn" id="10_qbgiu"]
|
||||
[ext_resource type="PackedScene" uid="uid://g8t6dt0ye6n3" path="res://behaviours/timer_stddev.tscn" id="11_20lvf"]
|
||||
[ext_resource type="AudioStream" uid="uid://d0feiq5s6fnux" path="res://entities/imp_drag.wav" id="11_rydo5"]
|
||||
[ext_resource type="AudioStream" uid="uid://cwsg776c11xfc" path="res://entities/fall.ogg" id="12_0h21e"]
|
||||
[ext_resource type="PackedScene" uid="uid://cml7rqvyfuagx" path="res://behaviours/move_towards.tscn" id="14_qtr50"]
|
||||
|
@ -183,6 +185,22 @@ kind = &"Watcher"
|
|||
|
||||
[node name="MovementSampler" parent="." instance=ExtResource("4_i1htf")]
|
||||
|
||||
[node name="MovementTilt" parent="." instance=ExtResource("9_xig8d")]
|
||||
min_rotation_speed = -120.0
|
||||
max_rotation_speed = 120.0
|
||||
speed = 44.0
|
||||
direction = Vector2(1, 0)
|
||||
|
||||
[node name="TiltPriority" parent="MovementTilt" instance=ExtResource("9_wtsor")]
|
||||
default_priority = 10
|
||||
alternative_priority = 10
|
||||
|
||||
[node name="TimerStddev" parent="MovementTilt" instance=ExtResource("11_20lvf")]
|
||||
autostart = true
|
||||
deviation = 0.3
|
||||
min_secs = 0.5
|
||||
max_secs = 1.5
|
||||
|
||||
[node name="MovementTrap" parent="." instance=ExtResource("14_qtr50")]
|
||||
speed = 600.0
|
||||
enabled = false
|
||||
|
@ -223,6 +241,10 @@ stream = ExtResource("12_0h21e")
|
|||
bus = &"FallSounds"
|
||||
|
||||
[connection signal="sacrificed" from="Sacrificable" to="." method="queue_free"]
|
||||
[connection signal="move" from="MovementTilt" to="." method="_on_move"]
|
||||
[connection signal="ready" from="MovementTilt" to="MovementTilt" method="randomize_direction"]
|
||||
[connection signal="ready" from="MovementTilt" to="MovementTilt" method="randomize_rotation_speed"]
|
||||
[connection signal="timeout" from="MovementTilt/TimerStddev" to="MovementTilt" method="randomize_rotation_speed"]
|
||||
[connection signal="changed_target" from="MovementTrap" to="MovementTrap/TrapPriority" method="priority_conditional"]
|
||||
[connection signal="move" from="MovementTrap" to="." method="_on_move"]
|
||||
[connection signal="move_disabled" from="MovementTrap" to="." method="_on_freed"]
|
||||
|
|
Loading…
Reference in a new issue