Renamed to velocity controller
This commit is contained in:
parent
d1d33f3087
commit
8e9f246e2a
|
|
@ -22,7 +22,7 @@ onready var desired_movement_vector: Vector2 = Vector2(0,0)
|
|||
# Since animactor state machine can actually view properties from this type
|
||||
# I'm thinking about moving the velocity tracker in here instead of player.
|
||||
#var velocity = Vector2(0,0)
|
||||
var velocity :VelocityCalculations = VelocityCalculations.new()
|
||||
var velocity_controller :VelocityController = VelocityController.new()
|
||||
|
||||
#Removing Probably not used
|
||||
#var sim_velocity = Vector2(0,0)
|
||||
|
|
@ -159,5 +159,5 @@ func apply_movement_to_parent( _velocity :Vector2) -> void:
|
|||
if _velocity.y < -8:
|
||||
snap = Vector2.ZERO
|
||||
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)
|
||||
|
||||
|
|
|
|||
|
|
@ -165,9 +165,9 @@ _global_script_classes=[ {
|
|||
"path": "res://src/ui/HUD.gd"
|
||||
}, {
|
||||
"base": "Reference",
|
||||
"class": "VelocityCalculations",
|
||||
"class": "VelocityController",
|
||||
"language": "GDScript",
|
||||
"path": "res://src/classes/velocity_calculations.gd"
|
||||
"path": "res://src/classes/velocity_controller.gd"
|
||||
} ]
|
||||
_global_script_class_icons={
|
||||
"Actor": "",
|
||||
|
|
@ -201,7 +201,7 @@ _global_script_class_icons={
|
|||
"StateModifierAnimatedActor": "",
|
||||
"StateModifierMovement": "",
|
||||
"UIComponent": "",
|
||||
"VelocityCalculations": ""
|
||||
"VelocityController": ""
|
||||
}
|
||||
|
||||
[application]
|
||||
|
|
|
|||
|
|
@ -163,7 +163,7 @@ func _state_process_physics_idle():
|
|||
# var _v :Vector2 = new_move_actor_as_desired( physics_delta , current_state )
|
||||
# apply_movement_to_parent(_v)
|
||||
apply_movement_to_parent(
|
||||
velocity.calculate_velocity(
|
||||
velocity_controller.calculate_velocity(
|
||||
physics_delta ,
|
||||
apply_state_modifier(current_state.get_movement_parameters()),
|
||||
desired_movement_vector )
|
||||
|
|
@ -228,7 +228,7 @@ func _state_process_physics_roll():
|
|||
#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(
|
||||
velocity.calculate_velocity(
|
||||
velocity_controller.calculate_velocity(
|
||||
physics_delta ,
|
||||
apply_state_modifier(current_state.get_movement_parameters()),
|
||||
parent.transform.x )
|
||||
|
|
@ -263,7 +263,7 @@ func _state_process_physics_enter_right():
|
|||
# instead of movement direction
|
||||
#move_actor_as_desired(parent.transform.x.x)
|
||||
apply_movement_to_parent(
|
||||
velocity.calculate_velocity(
|
||||
velocity_controller.calculate_velocity(
|
||||
physics_delta ,
|
||||
apply_state_modifier(current_state.get_movement_parameters()),
|
||||
parent.transform.x )
|
||||
|
|
@ -279,7 +279,7 @@ func _state_process_physics_land():
|
|||
request_state_change.call_func('fall')
|
||||
#move_actor_as_desired()
|
||||
apply_movement_to_parent(
|
||||
velocity.calculate_velocity(
|
||||
velocity_controller.calculate_velocity(
|
||||
physics_delta ,
|
||||
apply_state_modifier(current_state.get_movement_parameters()),
|
||||
desired_movement_vector )
|
||||
|
|
@ -292,14 +292,14 @@ func _state_process_physics_hurt():
|
|||
# if !parent.is_on_floor():
|
||||
# #return fall_state
|
||||
# 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))
|
||||
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):
|
||||
# parent.velocity.x = 1 * move_speed
|
||||
# else:
|
||||
# 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():
|
||||
|
|
@ -318,7 +318,7 @@ func _state_process_physics_fall():
|
|||
|
||||
#move_actor_as_desired()
|
||||
apply_movement_to_parent(
|
||||
velocity.calculate_velocity(
|
||||
velocity_controller.calculate_velocity(
|
||||
physics_delta ,
|
||||
apply_state_modifier(current_state.get_movement_parameters()),
|
||||
desired_movement_vector )
|
||||
|
|
@ -333,12 +333,12 @@ func _state_process_physics_jump():
|
|||
# #modifier.reference()
|
||||
# #idle_state.modifier = landing_modifier
|
||||
# request_state_change.call_func('idle')
|
||||
if velocity.velocity.y > 0:
|
||||
if velocity_controller.velocity.y > 0:
|
||||
request_state_change.call_func('fall')
|
||||
desired_movement_vector.y = UP
|
||||
#move_actor_as_desired()
|
||||
apply_movement_to_parent(
|
||||
velocity.calculate_velocity(
|
||||
velocity_controller.calculate_velocity(
|
||||
physics_delta ,
|
||||
apply_state_modifier(current_state.get_movement_parameters()),
|
||||
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(
|
||||
velocity.calculate_velocity(
|
||||
velocity_controller.calculate_velocity(
|
||||
physics_delta ,
|
||||
apply_state_modifier(current_state.get_movement_parameters()),
|
||||
desired_movement_vector )
|
||||
|
|
@ -415,7 +415,7 @@ func _state_process_physics_climb():
|
|||
|
||||
func _state_process_physics_ledge_grab():
|
||||
if debug_component:
|
||||
UiManager.debug_text = (str(velocity))
|
||||
UiManager.debug_text = (str(velocity_controller.velocity))
|
||||
$"%LedgeDetector".set_enabled(false)
|
||||
|
||||
if _wants_jump:
|
||||
|
|
@ -429,7 +429,7 @@ func _state_process_physics_ledge_climb():
|
|||
|
||||
if debug_component:
|
||||
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:
|
||||
request_state_change.call_func('land')
|
||||
|
|
@ -482,7 +482,7 @@ func _state_process_physics_crouch_move():
|
|||
|
||||
#move_actor_as_desired()
|
||||
apply_movement_to_parent(
|
||||
velocity.calculate_velocity(
|
||||
velocity_controller.calculate_velocity(
|
||||
physics_delta ,
|
||||
apply_state_modifier(current_state.get_movement_parameters()),
|
||||
desired_movement_vector )
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
class_name VelocityCalculations
|
||||
class_name VelocityController
|
||||
|
||||
var velocity :Vector2
|
||||
var debug :bool = false
|
||||
Loading…
Reference in New Issue
Block a user