Moved setting speeds to inside set_condition instead of physics_process

This commit is contained in:
2024-06-03 23:46:36 -05:00
parent f21da74555
commit 07b135208e
4 changed files with 32 additions and 34 deletions

View File

@ -3,7 +3,7 @@ extends CharacterBody3D
#Condition Effect
enum CONDITION {NORMAL, SPRINTING, VAPING, COUGHING, SEVERE_COUGHING}
@export var current_condition = CONDITION.NORMAL
@export var current_condition:CONDITION = CONDITION.NORMAL
const SPEED_NORMAL = 5.0
const SPEED_SPRINTING = 8.0
@ -11,7 +11,7 @@ const SPEED_VAPING = 4.5
const SPEED_SLOWED = 3.0
const SPEED_IMMOBILE = 0.0
const JUMP_VELOCITY = 4.5
var current_speed
var current_speed = SPEED_NORMAL
var will_cough = false
var timealive = 0
@ -28,18 +28,6 @@ var gravity = ProjectSettings.get_setting("physics/3d/default_gravity")
func _physics_process(delta):
if not is_paused:
match current_condition:
CONDITION.NORMAL:
current_speed = SPEED_NORMAL
CONDITION.SPRINTING:
current_speed = SPEED_SPRINTING
CONDITION.VAPING:
current_speed = SPEED_VAPING
CONDITION.COUGHING:
current_speed = SPEED_SLOWED
CONDITION.SEVERE_COUGHING:
current_speed = SPEED_IMMOBILE
# Add the gravity.
if not is_on_floor():
velocity.y -= gravity * delta
@ -59,7 +47,6 @@ func _physics_process(delta):
velocity.x = move_toward(velocity.x, 0, current_speed)
velocity.z = move_toward(velocity.z, 0, current_speed)
move_and_slide()
var look_velocity = Input.get_vector("look_left", "look_right", "look_up", "look_down")
@ -102,27 +89,32 @@ func _input(event):
func set_condition(con):
current_condition = con
print("Setting Condition to ", con)
match con:
CONDITION.VAPING:
vapes_per_min += 1
$Head/VapeLight.on()
$"Coughing Timer".start()
$"Severe Coughing Timer".start()
current_speed = SPEED_VAPING
CONDITION.NORMAL:
$Head/VapeLight.off()
$"Coughing Timer".stop()
$"Severe Coughing Timer".stop()
current_speed = SPEED_NORMAL
CONDITION.COUGHING:
$Head/VapeLight.off()
$"Coughing Recovery".start()
$"Severe Coughing Timer".stop()
current_speed = SPEED_SLOWED
GlobalSettings.Player_Last_Location = global_transform.origin
CONDITION.SEVERE_COUGHING:
$Head/VapeLight.off()
$"Severe Coughing Recovery".start()
$"Coughing Timer".stop()
current_speed = SPEED_IMMOBILE
GlobalSettings.Player_Last_Location = global_transform.origin
CONDITION.SPRINTING:
current_speed = SPEED_SPRINTING
func recover():
will_cough = false