FPS Controller

This commit is contained in:
2025-11-13 08:05:46 -05:00
parent c6e4d4f725
commit 14000f0096
177 changed files with 6311 additions and 7 deletions

View File

@@ -0,0 +1,11 @@
extends PlayerState
func _on_airborne_state_physics_processing(_delta: float) -> void:
if player_controller.is_on_floor():
if player_controller.check_fall_speed():
player_controller.camera_effects.add_fall_kick(2.0)
player_controller.state_chart.send_event("onGrounded")
player_controller.current_fall_velocity += player_controller.velocity.y

View File

@@ -0,0 +1 @@
uid://u17omde74n8t

View File

@@ -0,0 +1,10 @@
class_name PlayerState extends Node
@export var debug : bool = false
var player_controller : PlayerController
func _ready() -> void:
if %StateMachine and %StateMachine is PlayerStateMachine:
player_controller = %StateMachine.player_controller

View File

@@ -0,0 +1 @@
uid://yeyejbcbr1da

View File

@@ -0,0 +1,12 @@
extends PlayerState
func _on_crouching_state_physics_processing(delta: float) -> void:
player_controller.camera.update_camera_height(delta, -1)
if not Input.is_action_pressed("crouch") and player_controller.is_on_floor() and not player_controller.crouch_check.is_colliding():
player_controller.state_chart.send_event("onStanding")
func _on_crouching_state_entered() -> void:
player_controller.crouch()

View File

@@ -0,0 +1 @@
uid://bnmnicp5nu3u2

View File

@@ -0,0 +1,10 @@
extends PlayerState
func _on_grounded_state_physics_processing(delta: float) -> void:
if Input.is_action_just_pressed("jump") and player_controller.is_on_floor():
player_controller.jump()
player_controller.state_chart.send_event("onAirborne")
if not player_controller.is_on_floor():
player_controller.state_chart.send_event("onAirborne")

View File

@@ -0,0 +1 @@
uid://dk8ukj487ryhj

View File

@@ -0,0 +1,6 @@
extends PlayerState
func _on_idle_state_processing(delta: float) -> void:
if player_controller and player_controller._input_dir.length() > 0:
player_controller.state_chart.send_event("onMoving")

View File

@@ -0,0 +1 @@
uid://d03p2engkhyjc

View File

@@ -0,0 +1,6 @@
extends PlayerState
func _on_moving_state_physics_processing(delta: float) -> void:
if player_controller._input_dir.length() == 0 and player_controller.velocity.length() < 0.5:
player_controller.state_chart.send_event("onIdle")

View File

@@ -0,0 +1 @@
uid://dc5dk6fyv83gt

View File

@@ -0,0 +1,10 @@
extends PlayerState
func _on_sprinting_state_processing(delta: float) -> void:
if not Input.is_action_pressed("sprint"):
player_controller.state_chart.send_event("onWalking")
func _on_sprinting_state_entered() -> void:
player_controller.sprint()

View File

@@ -0,0 +1 @@
uid://b40akfam2xgt

View File

@@ -0,0 +1,12 @@
extends PlayerState
func _on_standing_state_physics_processing(delta: float) -> void:
player_controller.camera.update_camera_height(delta, 1)
if Input.is_action_pressed("crouch") and player_controller.is_on_floor():
player_controller.state_chart.send_event("onCrouching")
func _on_standing_state_entered() -> void:
player_controller.stand()

View File

@@ -0,0 +1 @@
uid://c1eixxgwl2exy

View File

@@ -0,0 +1,10 @@
extends PlayerState
func _on_walking_state_processing(delta: float) -> void:
if Input.is_action_pressed("sprint"):
player_controller.state_chart.send_event("onSprinting")
func _on_walking_state_entered() -> void:
player_controller.walk()

View File

@@ -0,0 +1 @@
uid://bstd2nopn6ur