mirror of
https://github.com/Steffo99/hella-farm.git
synced 2024-11-21 15:44:23 +00:00
It works
This commit is contained in:
parent
3341c86e39
commit
8278a55069
3 changed files with 12 additions and 4 deletions
|
@ -7,6 +7,8 @@ class_name MoveStraight
|
|||
signal changed_direction(new: Vector2)
|
||||
|
||||
|
||||
@export var speed: float = 100.0
|
||||
|
||||
@export var direction: Vector2:
|
||||
get:
|
||||
return direction
|
||||
|
@ -25,9 +27,9 @@ func randomize_direction() -> void:
|
|||
direction = Vector2.from_angle(Random.rng.randf_range(0, 2*PI))
|
||||
|
||||
|
||||
func _physics_process(_delta: float) -> void:
|
||||
func _physics_process(delta: float) -> void:
|
||||
if enabled:
|
||||
move.emit(direction)
|
||||
move.emit(direction * delta * speed)
|
||||
|
||||
func _on_changed_direction(new: Vector2) -> void:
|
||||
Log.p(self, "Changed direction to: %s" % new)
|
||||
|
|
|
@ -8,6 +8,8 @@ class_name MoveTowards
|
|||
signal changed_target(new: Node2D)
|
||||
|
||||
|
||||
@export var speed: float = 100.0
|
||||
|
||||
@export var target: Node2D = null:
|
||||
get:
|
||||
return target
|
||||
|
@ -23,12 +25,12 @@ func clear_target() -> void:
|
|||
target = null
|
||||
|
||||
|
||||
func _physics_process(_delta: float) -> void:
|
||||
func _physics_process(delta: float) -> void:
|
||||
if enabled:
|
||||
if target:
|
||||
var gap = target.global_position - global_position
|
||||
var norm = gap.normalized()
|
||||
move.emit(norm)
|
||||
move.emit(norm * delta * speed)
|
||||
else:
|
||||
move.emit(Vector2.ZERO)
|
||||
|
||||
|
|
|
@ -117,6 +117,7 @@ libraries = {
|
|||
possibilities = [NodePath("../MovementIdle/IdlePriority"), NodePath("../MovementWander/WanderPriority"), NodePath("../MovementRunFromMouse/RunFromMousePriority"), NodePath("../MovementRunFromHunter/RunFromHunterPriority")]
|
||||
|
||||
[node name="MovementIdle" parent="." instance=ExtResource("10_05kcd")]
|
||||
speed = 0.0
|
||||
enabled = false
|
||||
|
||||
[node name="IdlePriority" parent="MovementIdle" instance=ExtResource("11_0jlmk")]
|
||||
|
@ -126,6 +127,7 @@ priority = 10
|
|||
one_shot = true
|
||||
|
||||
[node name="MovementWander" parent="." instance=ExtResource("10_05kcd")]
|
||||
speed = 66.0
|
||||
enabled = false
|
||||
|
||||
[node name="WanderPriority" parent="MovementWander" instance=ExtResource("11_0jlmk")]
|
||||
|
@ -134,6 +136,7 @@ enabled = false
|
|||
one_shot = true
|
||||
|
||||
[node name="MovementRunFromMouse" parent="." instance=ExtResource("12_x2g3x")]
|
||||
speed = -100.0
|
||||
enabled = false
|
||||
|
||||
[node name="RunFromMousePriority" parent="MovementRunFromMouse" instance=ExtResource("11_0jlmk")]
|
||||
|
@ -145,6 +148,7 @@ shape = SubResource("CircleShape2D_etpf6")
|
|||
debug_color = Color(1, 0, 0, 0.0470588)
|
||||
|
||||
[node name="MovementRunFromHunter" parent="." instance=ExtResource("12_x2g3x")]
|
||||
speed = -100.0
|
||||
enabled = false
|
||||
|
||||
[node name="RunFromHunterPriority" parent="MovementRunFromHunter" instance=ExtResource("11_0jlmk")]
|
||||
|
|
Loading…
Reference in a new issue