This commit is contained in:
Marek Lenczewski
2026-04-01 22:53:28 +02:00
parent b236cd52cb
commit e76c66eda6
70 changed files with 1016 additions and 732 deletions

View File

@@ -1,8 +1,5 @@
extends Node
const SPEED := 5.0
const JUMP_VELOCITY := 4.5
var gravity: float = ProjectSettings.get_setting("physics/3d/default_gravity")
@onready var player: CharacterBody3D = get_parent()
@@ -11,8 +8,12 @@ func _physics_process(delta: float) -> void:
if not player.is_on_floor():
player.velocity.y -= gravity * delta
var base: BaseStats = Stats.get_base(player)
var speed: float = base.speed if base is PlayerStats else 5.0
var jump_velocity: float = base.jump_velocity if base is PlayerStats else 4.5
if Input.is_action_just_pressed("ui_accept") and player.is_on_floor():
player.velocity.y = JUMP_VELOCITY
player.velocity.y = jump_velocity
var input_dir := Input.get_vector("move_left", "move_right", "move_forward", "move_back")
var camera_pivot := player.get_node("CameraPivot") as Node3D
@@ -26,10 +27,10 @@ func _physics_process(delta: float) -> void:
var direction := (forward * -input_dir.y + right * input_dir.x).normalized()
if direction:
player.velocity.x = direction.x * SPEED
player.velocity.z = direction.z * SPEED
player.velocity.x = direction.x * speed
player.velocity.z = direction.z * speed
else:
player.velocity.x = move_toward(player.velocity.x, 0, SPEED)
player.velocity.z = move_toward(player.velocity.z, 0, SPEED)
player.velocity.x = move_toward(player.velocity.x, 0, speed)
player.velocity.z = move_toward(player.velocity.z, 0, speed)
player.move_and_slide()