This commit is contained in:
Nyx
2025-08-26 13:24:16 -06:00
57 changed files with 5143 additions and 0 deletions

View File

@@ -0,0 +1,52 @@
extends CharacterBody3D
class_name PlayerController
@onready var springarm:SpringArm3D = $Pivot/SpringArm3D
@export_category("Movement")
@export var speed:float = 14.0
@export var fall_acceleration:float = 75.0
@export var jump_speed:float = 10
@export_category("Camera")
@export var max_look_up:float = 80.0
@export var max_look_down:float = -80.0
@export var mouse_sensitivity:float= 0.15
@export var joystick_sensitivity:float = 100.00
var target_velocity:Vector3 = Vector3.ZERO
func _ready() -> void:
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
func _physics_process(delta: float) -> void:
var direction_2d = Input.get_vector(&"move_left",&"move_right",&"move_back",&"move_forward")
var direction_3d = (transform.basis.x * direction_2d.x + -transform.basis.z * direction_2d.y).normalized()
velocity.x = direction_3d.x*speed
velocity.z = direction_3d.z*speed
if not is_on_floor():
velocity.y -= fall_acceleration * delta
move_and_slide()
func _process(delta: float) -> void:
var horiz = Input.get_axis(&"look_right",&"look_left")
var vert = Input.get_axis(&"look_down",&"look_up")
var camera_direction = Input.get_vector(&"look_right",&"look_left",&"look_down",&"look_up")
if camera_direction != Vector2.ZERO:
_apply_look(Vector2(horiz, vert)*(joystick_sensitivity*delta))
func _input(event: InputEvent) -> void:
# mouse look (unchanged)
if event is InputEventMouseMotion and Input.get_mouse_mode() == Input.MOUSE_MODE_CAPTURED:
_apply_look(Vector2(-event.relative.x, -event.relative.y) * mouse_sensitivity)
if event.is_action_pressed(&"jump") and is_on_floor():
_jump()
func _apply_look(delta: Vector2) -> void:
rotate_y(deg_to_rad(delta.x))
var new_pitch = springarm.rotation_degrees.x + delta.y
springarm.rotation_degrees.x = clamp(new_pitch,max_look_down,max_look_up)
func _jump() -> void:
velocity.y = jump_speed

View File

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

View File

@@ -0,0 +1,21 @@
extends Node
class_name HealthComponenent
signal hp_changed(current_hp)
signal died()
@export var data: HealthResource
var current_hp: float
func _ready() -> void:
current_hp = data.max_hp
func _take_damage(amount:float )->void:
current_hp = max(current_hp-amount,0)
emit_signal(&"hp_changed", current_hp)
if current_hp == 0:
emit_signal(&"died")
func _heal(amount:float)->void:
current_hp= min(current_hp+amount, data.max_hp)
emit_signal(&"hp_changed",current_hp)

View File

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

View File

@@ -0,0 +1,6 @@
extends Resource
class_name HealthResource
@export var max_hp:int = 100
@export var regen_per_second:float = 0.0

View File

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