Browse Source

:wrench: Implement main action stop

Useful to stop thrust.
DricomDragon 1 year ago
parent
commit
99b01de319

+ 7 - 4
first3d/component/entity/plane/tiny_plane.gd

@@ -12,8 +12,11 @@ var target_rotation := Vector3.ZERO
 var target_thrust := Vector3.ZERO
 
 
-func trigger_thrust() -> void:
-	target_thrust = Vector3.FORWARD * thrust_power + Vector3.UP * lift
+func trigger_thrust(activate: bool) -> void:
+	if activate:
+		target_thrust = Vector3.FORWARD * thrust_power + Vector3.UP * lift
+	else:
+		target_thrust = Vector3.ZERO
 
 
 func trigger_direction(dir: Vector2) -> void:
@@ -31,5 +34,5 @@ func _on_dir_changed(dir: Vector2) -> void:
 	trigger_direction(dir)
 
 
-func _on_main_action() -> void:
-	trigger_thrust()
+func _on_main_action(pressed: bool) -> void:
+	trigger_thrust(pressed)

+ 3 - 2
first3d/component/entity/walker/walker.gd

@@ -42,5 +42,6 @@ func _on_dir_changed(dir: Vector2) -> void:
 	trigger_direction(dir)
 
 
-func _on_main_action() -> void:
-	trigger_jump()
+func _on_main_action(pressed: bool) -> void:
+	if pressed:
+		trigger_jump()

+ 3 - 3
first3d/flow/control/local_input/local_input.gd

@@ -3,11 +3,11 @@ extends Node
 # Sends commands from a local device
 
 signal dir_changed(new_dir: Vector2)
-signal main_action
+signal main_action(pressed: bool)
 
 func _unhandled_input(event: InputEvent) -> void:
-	if event.is_action_pressed("jump"):
-		main_action.emit()
+	if event.is_action("jump"):
+		main_action.emit(event.is_pressed())
 	elif event is InputEventJoypadMotion:
 		var dir: Vector2 = Input.get_vector("move_left", "move_right", "move_back", "move_forward")
 		dir_changed.emit(dir)