Godot 4.5.1

This commit is contained in:
2025-12-14 22:43:11 +10:00
parent 5805ac2260
commit 4dd1ce64f5
433 changed files with 2922 additions and 585 deletions

View File

@@ -17,69 +17,69 @@ var _running:bool = false
# Private Methods
#
func _applyGravity() -> void:
if !body.is_on_floor():
body.velocity += PHYSICS.GRAVITY * get_process_delta_time()
if !body.is_on_floor():
body.velocity += PHYSICS.GRAVITY * get_process_delta_time()
func _applyMovement() -> void:
if !canMove():
return
if !canMove():
return
var cameraCurrent = get_viewport().get_camera_3d()
if !cameraCurrent:
return
var cameraCurrent = get_viewport().get_camera_3d()
if !cameraCurrent:
return
# Use camera orientation for movement direction
var camBasis = cameraCurrent.global_transform.basis
# Use camera orientation for movement direction
var camBasis = cameraCurrent.global_transform.basis
# Forward and right vectors, ignore vertical component
var forward = -camBasis.z
forward.y = 0
forward = forward.normalized()
var right = camBasis.x
right.y = 0
right = right.normalized()
# Forward and right vectors, ignore vertical component
var forward = -camBasis.z
forward.y = 0
forward = forward.normalized()
var right = camBasis.x
right.y = 0
right = right.normalized()
var directionAdjusted = (
forward * _inputDir.y + right * _inputDir.x
).normalized()
if directionAdjusted.length() <= 0.01:
return
var directionAdjusted = (
forward * _inputDir.y + right * _inputDir.x
).normalized()
if directionAdjusted.length() <= 0.01:
return
if rotate:
var targetRot = atan2(directionAdjusted.x, directionAdjusted.z)
rotate.rotation.y = targetRot
if rotate:
var targetRot = atan2(directionAdjusted.x, directionAdjusted.z)
rotate.rotation.y = targetRot
var speed = walkSpeed
if _running:
speed = runSpeed
body.velocity.x = directionAdjusted.x * speed
body.velocity.z = directionAdjusted.z * speed
var speed = walkSpeed
if _running:
speed = runSpeed
body.velocity.x = directionAdjusted.x * speed
body.velocity.z = directionAdjusted.z * speed
func _applyFriction(delta:float) -> void:
body.velocity.x *= delta * FRICTION
body.velocity.z *= delta * FRICTION
body.velocity.x *= delta * FRICTION
body.velocity.z *= delta * FRICTION
#
# Protected Methods
# Protected Methods
#
func canMove() -> bool:
return true
return true
#
# Callbacks
#
func _enter_tree() -> void:
pass
pass
func _physics_process(delta:float) -> void:
if Engine.is_editor_hint():
return
if Engine.is_editor_hint():
return
if !body:
return
if !body:
return
_applyGravity()
_applyFriction(delta)
_applyMovement()
body.move_and_slide()
_applyGravity()
_applyFriction(delta)
_applyMovement()
body.move_and_slide()