## PlayerNetInput — netfox BaseNetInput subclass for tactical-shooter. ## ## This node lives under the Player scene and gathers input each network ## tick. RollbackSynchronizer references its properties in `input_properties`. ## ## Usage: ## Place as a child of the Player (CharacterBody3D or Node3D). ## The RollbackSynchronizer on the player's parent node will call ## _gather() before each tick, reading these exported properties. extends BaseNetInput class_name PlayerNetInput # --------------------------------------------------------------------------- # Input state — read by RollbackSynchronizer as input_properties # These are set in _gather() on the authority peer before every tick. # --------------------------------------------------------------------------- ## Movement direction in local space (normalized, or zero). @export var move_direction: Vector3 = Vector3.ZERO ## Mouse look: yaw (horizontal, radians). @export var look_yaw: float = 0.0 ## Mouse look: pitch (vertical, radians). @export var look_pitch: float = 0.0 ## Jump pressed this tick. @export var jump: bool = false ## Sprint toggle active. @export var sprint: bool = false ## Crouch toggle active. @export var crouch: bool = false ## Shoot pressed this tick. @export var shoot: bool = false ## Aim-down-sights pressed. @export var aim: bool = false # --------------------------------------------------------------------------- # Input gathering (called before each tick on the authority peer) # --------------------------------------------------------------------------- func _gather() -> void: # Movement direction var dir := Vector3.ZERO if Input.is_action_pressed(&"move_forward") or Input.is_action_pressed(&"move_up"): dir.z -= 1.0 if Input.is_action_pressed(&"move_backward") or Input.is_action_pressed(&"move_down"): dir.z += 1.0 if Input.is_action_pressed(&"move_left"): dir.x -= 1.0 if Input.is_action_pressed(&"move_right"): dir.x += 1.0 if dir.length_squared() > 0.0: dir = dir.normalized() move_direction = dir # Mouse look is handled in fps_character_controller.gd _input() # and synced here via the character controller's current yaw/pitch. # If this node has a FPSCharacterController sibling, read from it. var parent := get_parent() if parent and parent.has_method(&"get_current_yaw"): look_yaw = parent.get_current_yaw() if parent and parent.has_method(&"get_current_pitch"): look_pitch = parent.get_current_pitch() # Action inputs jump = Input.is_action_just_pressed(&"jump") sprint = Input.is_action_pressed(&"sprint") crouch = Input.is_action_pressed(&"crouch") shoot = Input.is_action_pressed(&"shoot") aim = Input.is_action_pressed(&"aim")