fix: Vacuum moves screen independent
This commit is contained in:
parent
a32e99cf42
commit
1c5caa5d29
@ -11,7 +11,7 @@ func _ready() -> void:
|
||||
|
||||
|
||||
# TODO Only moves when on screen
|
||||
func _physics_process(delta: float) -> void:
|
||||
func execute_movement(delta: float) -> void:
|
||||
velocity.y += _gravity * delta
|
||||
var player_direction := player_on_floor_direction()
|
||||
if(player_direction != 0):
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
[gd_scene load_steps=6 format=2]
|
||||
[gd_scene load_steps=7 format=2]
|
||||
|
||||
[ext_resource path="res://assets/enemy/VacuumRobot.png" type="Texture" id=1]
|
||||
[ext_resource path="res://src/Actors/Enemies/Vacuum.gd" type="Script" id=2]
|
||||
[ext_resource path="res://src/StateMachines/VacuumStateMachine.gd" type="Script" id=3]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id=1]
|
||||
extents = Vector2( 14, 7 )
|
||||
@ -14,8 +15,9 @@ extents = Vector2( 15, 6.5 )
|
||||
|
||||
[node name="Vacuum" type="KinematicBody2D" groups=["harmful"]]
|
||||
collision_layer = 2
|
||||
collision_mask = 9
|
||||
collision_mask = 11
|
||||
script = ExtResource( 2 )
|
||||
mass = 1.0
|
||||
speed = 180
|
||||
acceleration = 100
|
||||
|
||||
@ -70,6 +72,9 @@ collision_mask = 127
|
||||
position = Vector2( 0, 5.5 )
|
||||
shape = SubResource( 3 )
|
||||
|
||||
[node name="StateMachine" type="Node" parent="."]
|
||||
script = ExtResource( 3 )
|
||||
|
||||
[connection signal="body_entered" from="StompDetector" to="." method="_on_StompDetector_body_entered"]
|
||||
[connection signal="area_entered" from="EnemySkin" to="." method="_on_EnemySkin_area_entered"]
|
||||
[connection signal="body_entered" from="EnemySkin" to="." method="_on_EnemySkin_body_entered"]
|
||||
|
||||
32
src/StateMachines/VacuumStateMachine.gd
Normal file
32
src/StateMachines/VacuumStateMachine.gd
Normal file
@ -0,0 +1,32 @@
|
||||
extends StateMachine
|
||||
|
||||
func _ready() -> void:
|
||||
add_state("darting")
|
||||
state = states.darting
|
||||
set_state(states.darting)
|
||||
for state in states:
|
||||
if state_matching_method_exists(state):
|
||||
continue
|
||||
else:
|
||||
printerr("StateMachine -> State: " + state + " has no matching method in parent.")
|
||||
push_error("StateMachine -> State: " + state + " has no matching method in parent.")
|
||||
# _animation_logic()
|
||||
|
||||
|
||||
# Game logic consequences of state
|
||||
func _state_logic(delta):
|
||||
#var state_action_ref = funcref(parent, self.state)
|
||||
#parent.velocity = state_action_ref.call_func()
|
||||
parent.execute_movement(delta)
|
||||
|
||||
|
||||
func _get_transition(_delta):
|
||||
return null
|
||||
|
||||
|
||||
func _enter_state(_new_state, _previous_state):
|
||||
pass
|
||||
|
||||
|
||||
func _exit_state(_previous_state, _new_state):
|
||||
pass
|
||||
Loading…
Reference in New Issue
Block a user