Renamed to velocity controller

This commit is contained in:
Dustin 2025-05-09 21:49:58 -07:00
parent d1d33f3087
commit 8e9f246e2a
4 changed files with 20 additions and 20 deletions

View File

@ -22,7 +22,7 @@ onready var desired_movement_vector: Vector2 = Vector2(0,0)
# Since animactor state machine can actually view properties from this type # Since animactor state machine can actually view properties from this type
# I'm thinking about moving the velocity tracker in here instead of player. # I'm thinking about moving the velocity tracker in here instead of player.
#var velocity = Vector2(0,0) #var velocity = Vector2(0,0)
var velocity :VelocityCalculations = VelocityCalculations.new() var velocity_controller :VelocityController = VelocityController.new()
#Removing Probably not used #Removing Probably not used
#var sim_velocity = Vector2(0,0) #var sim_velocity = Vector2(0,0)
@ -159,5 +159,5 @@ func apply_movement_to_parent( _velocity :Vector2) -> void:
if _velocity.y < -8: if _velocity.y < -8:
snap = Vector2.ZERO snap = Vector2.ZERO
if parent is KinematicBody2D: if parent is KinematicBody2D:
velocity.velocity = parent.move_and_slide_with_snap(_velocity, snap , Vector2.UP, true) velocity_controller.velocity = parent.move_and_slide_with_snap(_velocity, snap , Vector2.UP, true)

View File

@ -165,9 +165,9 @@ _global_script_classes=[ {
"path": "res://src/ui/HUD.gd" "path": "res://src/ui/HUD.gd"
}, { }, {
"base": "Reference", "base": "Reference",
"class": "VelocityCalculations", "class": "VelocityController",
"language": "GDScript", "language": "GDScript",
"path": "res://src/classes/velocity_calculations.gd" "path": "res://src/classes/velocity_controller.gd"
} ] } ]
_global_script_class_icons={ _global_script_class_icons={
"Actor": "", "Actor": "",
@ -201,7 +201,7 @@ _global_script_class_icons={
"StateModifierAnimatedActor": "", "StateModifierAnimatedActor": "",
"StateModifierMovement": "", "StateModifierMovement": "",
"UIComponent": "", "UIComponent": "",
"VelocityCalculations": "" "VelocityController": ""
} }
[application] [application]

View File

@ -163,7 +163,7 @@ func _state_process_physics_idle():
# var _v :Vector2 = new_move_actor_as_desired( physics_delta , current_state ) # var _v :Vector2 = new_move_actor_as_desired( physics_delta , current_state )
# apply_movement_to_parent(_v) # apply_movement_to_parent(_v)
apply_movement_to_parent( apply_movement_to_parent(
velocity.calculate_velocity( velocity_controller.calculate_velocity(
physics_delta , physics_delta ,
apply_state_modifier(current_state.get_movement_parameters()), apply_state_modifier(current_state.get_movement_parameters()),
desired_movement_vector ) desired_movement_vector )
@ -228,7 +228,7 @@ func _state_process_physics_roll():
#move_actor_as_desired(parent.transform.x.x) #move_actor_as_desired(parent.transform.x.x)
#apply_movement_to_parent(new_move_actor_as_desired( physics_delta , current_state, parent.transform.x )) #apply_movement_to_parent(new_move_actor_as_desired( physics_delta , current_state, parent.transform.x ))
apply_movement_to_parent( apply_movement_to_parent(
velocity.calculate_velocity( velocity_controller.calculate_velocity(
physics_delta , physics_delta ,
apply_state_modifier(current_state.get_movement_parameters()), apply_state_modifier(current_state.get_movement_parameters()),
parent.transform.x ) parent.transform.x )
@ -263,7 +263,7 @@ func _state_process_physics_enter_right():
# instead of movement direction # instead of movement direction
#move_actor_as_desired(parent.transform.x.x) #move_actor_as_desired(parent.transform.x.x)
apply_movement_to_parent( apply_movement_to_parent(
velocity.calculate_velocity( velocity_controller.calculate_velocity(
physics_delta , physics_delta ,
apply_state_modifier(current_state.get_movement_parameters()), apply_state_modifier(current_state.get_movement_parameters()),
parent.transform.x ) parent.transform.x )
@ -279,7 +279,7 @@ func _state_process_physics_land():
request_state_change.call_func('fall') request_state_change.call_func('fall')
#move_actor_as_desired() #move_actor_as_desired()
apply_movement_to_parent( apply_movement_to_parent(
velocity.calculate_velocity( velocity_controller.calculate_velocity(
physics_delta , physics_delta ,
apply_state_modifier(current_state.get_movement_parameters()), apply_state_modifier(current_state.get_movement_parameters()),
desired_movement_vector ) desired_movement_vector )
@ -292,14 +292,14 @@ func _state_process_physics_hurt():
# if !parent.is_on_floor(): # if !parent.is_on_floor():
# #return fall_state # #return fall_state
# request_state_change.call_func('fall') # request_state_change.call_func('fall')
velocity.y += current_state.gravity * physics_delta velocity_controller.velocity.y += current_state.gravity * physics_delta
#parent.velocity = parent.move_and_slide(parent.velocity, Vector2(0, -1)) #parent.velocity = parent.move_and_slide(parent.velocity, Vector2(0, -1))
velocity.x = parent.transform.x.x * -1 * current_state.horizontal_speed velocity_controller.velocity.x = parent.transform.x.x * -1 * current_state.horizontal_speed
# if (parent.direction.x > 0): # if (parent.direction.x > 0):
# parent.velocity.x = 1 * move_speed # parent.velocity.x = 1 * move_speed
# else: # else:
# parent.velocity.x = -1 * move_speed # parent.velocity.x = -1 * move_speed
velocity.velocity = parent.move_and_slide(velocity.velocity, Vector2(0, -1)) velocity_controller.velocity = parent.move_and_slide(velocity_controller.velocity, Vector2(0, -1))
func _state_process_physics_fall(): func _state_process_physics_fall():
@ -318,7 +318,7 @@ func _state_process_physics_fall():
#move_actor_as_desired() #move_actor_as_desired()
apply_movement_to_parent( apply_movement_to_parent(
velocity.calculate_velocity( velocity_controller.calculate_velocity(
physics_delta , physics_delta ,
apply_state_modifier(current_state.get_movement_parameters()), apply_state_modifier(current_state.get_movement_parameters()),
desired_movement_vector ) desired_movement_vector )
@ -333,12 +333,12 @@ func _state_process_physics_jump():
# #modifier.reference() # #modifier.reference()
# #idle_state.modifier = landing_modifier # #idle_state.modifier = landing_modifier
# request_state_change.call_func('idle') # request_state_change.call_func('idle')
if velocity.velocity.y > 0: if velocity_controller.velocity.y > 0:
request_state_change.call_func('fall') request_state_change.call_func('fall')
desired_movement_vector.y = UP desired_movement_vector.y = UP
#move_actor_as_desired() #move_actor_as_desired()
apply_movement_to_parent( apply_movement_to_parent(
velocity.calculate_velocity( velocity_controller.calculate_velocity(
physics_delta , physics_delta ,
apply_state_modifier(current_state.get_movement_parameters()), apply_state_modifier(current_state.get_movement_parameters()),
desired_movement_vector ) desired_movement_vector )
@ -366,7 +366,7 @@ func _state_process_physics_move():
#apply_movement_to_parent(new_move_actor_as_desired( physics_delta , current_state )) #apply_movement_to_parent(new_move_actor_as_desired( physics_delta , current_state ))
apply_movement_to_parent( apply_movement_to_parent(
velocity.calculate_velocity( velocity_controller.calculate_velocity(
physics_delta , physics_delta ,
apply_state_modifier(current_state.get_movement_parameters()), apply_state_modifier(current_state.get_movement_parameters()),
desired_movement_vector ) desired_movement_vector )
@ -415,7 +415,7 @@ func _state_process_physics_climb():
func _state_process_physics_ledge_grab(): func _state_process_physics_ledge_grab():
if debug_component: if debug_component:
UiManager.debug_text = (str(velocity)) UiManager.debug_text = (str(velocity_controller.velocity))
$"%LedgeDetector".set_enabled(false) $"%LedgeDetector".set_enabled(false)
if _wants_jump: if _wants_jump:
@ -429,7 +429,7 @@ func _state_process_physics_ledge_climb():
if debug_component: if debug_component:
UiManager.debug_text = (str(parent.is_on_floor()) + UiManager.debug_text = (str(parent.is_on_floor()) +
str(parent.is_on_wall()) + ")\nV:" + str(velocity)) str(parent.is_on_wall()) + ")\nV:" + str(velocity_controller.velocity))
if current_state.animation_finished == true: if current_state.animation_finished == true:
request_state_change.call_func('land') request_state_change.call_func('land')
@ -482,7 +482,7 @@ func _state_process_physics_crouch_move():
#move_actor_as_desired() #move_actor_as_desired()
apply_movement_to_parent( apply_movement_to_parent(
velocity.calculate_velocity( velocity_controller.calculate_velocity(
physics_delta , physics_delta ,
apply_state_modifier(current_state.get_movement_parameters()), apply_state_modifier(current_state.get_movement_parameters()),
desired_movement_vector ) desired_movement_vector )

View File

@ -1,4 +1,4 @@
class_name VelocityCalculations class_name VelocityController
var velocity :Vector2 var velocity :Vector2
var debug :bool = false var debug :bool = false