Files
Super-Mario-Bros.-Remastere…/Scripts/Classes/States/Player/NoClip.gd
guzlad e48b7c2c0f [QoL] Noclip can be toggled, works w/o debug in leveltesting, some convenience functions. (#621)
* Some state machine functions to make code tidier in the future

* Added a function to Global to check if we're playtesting, for convenience

* Only allow noclip w/o debug in leveltesting, toggling added, kept jump key to exit
2025-10-18 00:24:50 +01:00

22 lines
634 B
GDScript
Executable File

extends PlayerState
const SLOW_SPEED := 300.0
const FAST_SPEED := 800.0
var old_layers := []
func enter(_msg := {}) -> void:
player.can_hurt = false
player.set_collision_mask_value(1, false)
player.set_collision_mask_value(2, false)
func physics_update(_delta: float) -> void:
player.velocity = Input.get_vector("move_left_0", "move_right_0", "move_up_0", "move_down_0") * (FAST_SPEED if Input.is_action_pressed("run_0") else SLOW_SPEED)
player.move_and_slide()
func exit() -> void:
player.can_hurt = false
player.set_collision_mask_value(1, true)
player.set_collision_mask_value(2, true)
player.velocity = Vector2.ZERO