Compare commits
No commits in common. "2d27e4254ec46295eb9a5c4e442aeae571545807" and "d1fade919cdd6538e9d393233c5d77a7f8df4afc" have entirely different histories.
2d27e4254e
...
d1fade919c
@ -4,11 +4,11 @@ extends RigidBody3D
|
|||||||
# of collisions. So that's why we're using a RigidBody3D instead.
|
# of collisions. So that's why we're using a RigidBody3D instead.
|
||||||
|
|
||||||
const MOVE_SPEED := 8.0
|
const MOVE_SPEED := 8.0
|
||||||
const SPRINT_MOVE_SPEED :=13
|
|
||||||
const ACCELLERATION := 30.0
|
const ACCELLERATION := 30.0
|
||||||
const DECELLERATION := 40.0
|
const DECELLERATION := 40.0
|
||||||
const JUMP_SPEED := 4.0
|
const JUMP_SPEED := 4.0
|
||||||
const MAX_NUMBER_OF_JUMPS := 2
|
const MAX_NUMBER_OF_JUMPS := 2
|
||||||
|
|
||||||
const MIN_FOV := 10
|
const MIN_FOV := 10
|
||||||
const MAX_FOV := 180
|
const MAX_FOV := 180
|
||||||
const ZOOM_FACTOR := 1.1 # Zoom out when >1, in when < 1
|
const ZOOM_FACTOR := 1.1 # Zoom out when >1, in when < 1
|
||||||
@ -37,9 +37,7 @@ var _jump_triggered := false
|
|||||||
@export var anim_idle_name := "Idle"
|
@export var anim_idle_name := "Idle"
|
||||||
@export var anim_walk_name := "Walk"
|
@export var anim_walk_name := "Walk"
|
||||||
@export var anim_jump_name := "Jump"
|
@export var anim_jump_name := "Jump"
|
||||||
@export var anim_run_name := "Run"
|
|
||||||
@export var anim_walk_speed_threshold := 0.25
|
@export var anim_walk_speed_threshold := 0.25
|
||||||
@export var anim_sprint_speed_threshold := 10.0
|
|
||||||
|
|
||||||
var jump_sound = preload("res://assets/audio/jump.ogg")
|
var jump_sound = preload("res://assets/audio/jump.ogg")
|
||||||
var audio_player = AudioStreamPlayer.new()
|
var audio_player = AudioStreamPlayer.new()
|
||||||
@ -119,13 +117,8 @@ func _integrate_forces(state):
|
|||||||
right = _last_move_right
|
right = _last_move_right
|
||||||
|
|
||||||
var dir := (right * input2v.x + forward * input2v.y).normalized()
|
var dir := (right * input2v.x + forward * input2v.y).normalized()
|
||||||
|
|
||||||
var target_v := dir * MOVE_SPEED
|
var target_v := dir * MOVE_SPEED
|
||||||
|
|
||||||
# Sprinting
|
|
||||||
if Input.is_key_pressed(KEY_SHIFT):
|
|
||||||
target_v = dir * SPRINT_MOVE_SPEED
|
|
||||||
|
|
||||||
var ax := ACCELLERATION if dir != Vector3.ZERO else DECELLERATION
|
var ax := ACCELLERATION if dir != Vector3.ZERO else DECELLERATION
|
||||||
linear_velocity.x = move_toward(linear_velocity.x, target_v.x, ax * state.step)
|
linear_velocity.x = move_toward(linear_velocity.x, target_v.x, ax * state.step)
|
||||||
linear_velocity.z = move_toward(linear_velocity.z, target_v.z, ax * state.step)
|
linear_velocity.z = move_toward(linear_velocity.z, target_v.z, ax * state.step)
|
||||||
@ -195,10 +188,6 @@ func _update_animation(on_floor: bool, velocity: Vector3) -> void:
|
|||||||
if _anim_player.current_animation != anim_jump_name:
|
if _anim_player.current_animation != anim_jump_name:
|
||||||
_anim_player.play(anim_jump_name)
|
_anim_player.play(anim_jump_name)
|
||||||
return
|
return
|
||||||
if on_floor and horizontal_speed > anim_sprint_speed_threshold and _anim_player.has_animation(anim_run_name):
|
|
||||||
if _anim_player.current_animation != anim_walk_name:
|
|
||||||
_anim_player.play(anim_walk_name)
|
|
||||||
return
|
|
||||||
if horizontal_speed > anim_walk_speed_threshold and _anim_player.has_animation(anim_walk_name):
|
if horizontal_speed > anim_walk_speed_threshold and _anim_player.has_animation(anim_walk_name):
|
||||||
if _anim_player.current_animation != anim_walk_name:
|
if _anim_player.current_animation != anim_walk_name:
|
||||||
_anim_player.play(anim_walk_name)
|
_anim_player.play(anim_walk_name)
|
||||||
@ -244,3 +233,4 @@ func exit_vehicle(exit_point: Node3D, vehicle_camera: Camera3D) -> void:
|
|||||||
vehicle_camera.current = false
|
vehicle_camera.current = false
|
||||||
if cam:
|
if cam:
|
||||||
cam.current = true
|
cam.current = true
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user