Redo some of the git ignore, and add a dash function

This commit is contained in:
Scottifermcg
2025-11-12 23:30:04 +00:00
parent f34fc3e022
commit e2d9a529aa
128 changed files with 91 additions and 703 deletions
+71 -1
View File
@@ -34,6 +34,15 @@ var gravity = ProjectSettings.get_setting("physics/3d/default_gravity")
@export var attack_cooldown: float = 0.5
var _attack_timer: float = 0.0
# Dash system
@export var dash_speed_multiplier: float = 2.0
@export var dash_duration: float = 0.25
@export var dash_cooldown: float = 4.0
var _dash_timer: float = 0.0
var _dash_cooldown_timer: float = 0.0
var _is_dashing: bool = false
var _dash_direction: Vector3 = Vector3.ZERO
func _enter_tree():
super._enter_tree()
$SpringArmOffset/SpringArm3D/Camera3D.current = is_multiplayer_authority()
@@ -99,8 +108,21 @@ func _process(delta):
if _attack_timer > 0:
_attack_timer -= delta
# Update dash timers
if _dash_timer > 0:
_dash_timer -= delta
if _dash_timer <= 0:
_is_dashing = false
if _dash_cooldown_timer > 0:
_dash_cooldown_timer -= delta
# Handle dash input
if Input.is_action_just_pressed("dash") and _dash_cooldown_timer <= 0 and not is_dead and is_on_floor():
_perform_dash()
# Handle attack input
if Input.is_action_just_pressed("attack") and _attack_timer <= 0 and not is_dead:
if Input.is_action_just_pressed("attack") and _attack_timer <= 0 and not is_dead and not _is_dashing:
_perform_attack()
func freeze():
@@ -110,6 +132,13 @@ func freeze():
_body.animate(Vector3.ZERO)
func _move() -> void:
# If dashing, use dash movement
if _is_dashing:
velocity.x = _dash_direction.x * _current_speed * dash_speed_multiplier
velocity.z = _dash_direction.z * _current_speed * dash_speed_multiplier
_body.apply_rotation(velocity)
return
var _input_direction: Vector2 = Vector2.ZERO
if is_multiplayer_authority():
_input_direction = Input.get_vector(
@@ -329,3 +358,44 @@ func _on_respawned():
if is_multiplayer_authority():
print("You respawned!")
## Dash system
func _perform_dash():
if not is_multiplayer_authority() or is_dead or not is_on_floor():
return
# Get current movement direction or use forward if no input
var _input_direction: Vector2 = Input.get_vector(
"move_left", "move_right",
"move_forward", "move_backward"
)
var _direction: Vector3
if _input_direction.length() > 0:
# Dash in input direction
_direction = transform.basis * Vector3(_input_direction.x, 0, _input_direction.y).normalized()
_direction = _direction.rotated(Vector3.UP, _spring_arm_offset.rotation.y)
else:
# Dash forward if no input
_direction = -transform.basis.z
_direction = _direction.rotated(Vector3.UP, _spring_arm_offset.rotation.y)
# Set dash parameters
_dash_direction = _direction
_is_dashing = true
_dash_timer = dash_duration
_dash_cooldown_timer = dash_cooldown
# Rotate character slightly forward during dash
if _body:
_body.rotation.x = -0.3 # Tilt forward slightly
# Animation is handled by the Body's animate function
# Reset rotation after dash
var tween = create_tween()
tween.tween_method(_reset_dash_rotation, -0.3, 0.0, dash_duration)
func _reset_dash_rotation(rotation_value: float):
if _body:
_body.rotation.x = rotation_value