variable waterpole spinning

This commit is contained in:
Haze Weathers 2025-02-27 04:23:32 -05:00
parent fd3facb076
commit 606fb98afc
2 changed files with 7 additions and 4 deletions

View file

@ -168,13 +168,15 @@ var _pole_stored_speed: float = 0.0
func _start_pole_spin() -> void: func _start_pole_spin() -> void:
_pole_stored_speed = flatten_vector(velocity).length() _pole_stored_speed = flatten_vector(velocity).length()
velocity = Vector3.ZERO velocity = Vector3.ZERO
floor_snap_length = 0.0
var pole_xz = flatten_vector(_attached_pole.global_position) var pole_xz = flatten_vector(_attached_pole.global_position)
var self_xz = flatten_vector(global_position) var self_xz = flatten_vector(global_position)
_pole_angle = Vector3.FORWARD.angle_to(self_xz - pole_xz) _pole_angle = Vector3.FORWARD.angle_to(self_xz - pole_xz)
func _process_pole_spin(delta: float) -> void: func _process_pole_spin(delta: float) -> void:
var speed_factor = inverse_lerp(0.0, power_scale, _pole_stored_speed)
# rise # rise
global_position.y += _attached_pole.rise_speed * delta global_position.y += lerpf(0.0, _attached_pole.rise_speed, speed_factor) * delta
global_position.y = clampf( global_position.y = clampf(
global_position.y, global_position.y,
_attached_pole.global_position.y, _attached_pole.global_position.y,
@ -182,7 +184,7 @@ func _process_pole_spin(delta: float) -> void:
) )
# spin # spin
_pole_angle += _attached_pole.spin_speed * delta _pole_angle += lerpf(0.0, _attached_pole.spin_speed, speed_factor) * delta
var pole_xz = flatten_vector(_attached_pole.global_position) var pole_xz = flatten_vector(_attached_pole.global_position)
var self_dir = Vector3.FORWARD.rotated(Vector3.UP, _pole_angle) var self_dir = Vector3.FORWARD.rotated(Vector3.UP, _pole_angle)
var self_xz = pole_xz + self_dir * _attached_pole.offset var self_xz = pole_xz + self_dir * _attached_pole.offset
@ -194,6 +196,7 @@ func _end_pole_spin() -> void:
var impulse = Vector3.FORWARD.rotated(Vector3.UP, _pole_angle) * _pole_stored_speed var impulse = Vector3.FORWARD.rotated(Vector3.UP, _pole_angle) * _pole_stored_speed
velocity.x = impulse.x velocity.x = impulse.x
velocity.z = impulse.z velocity.z = impulse.z
floor_snap_length = 0.1
#endregion #endregion

View file

@ -213,9 +213,9 @@ delay_in_seconds = "0.0"
[connection signal="charge_canceled" from="." to="Sounds/ChargeCancel" method="play"] [connection signal="charge_canceled" from="." to="Sounds/ChargeCancel" method="play"]
[connection signal="shot" from="." to="Sounds/Shoot" method="play"] [connection signal="shot" from="." to="Sounds/Shoot" method="play"]
[connection signal="state_physics_processing" from="StateChart/Root/Idle" to="." method="_apply_gravity"] [connection signal="state_physics_processing" from="StateChart/Root/Idle" to="." method="_apply_gravity"]
[connection signal="state_physics_processing" from="StateChart/Root/Moving" to="." method="_bounce_on_walls"]
[connection signal="state_physics_processing" from="StateChart/Root/Moving" to="." method="_slow_to_stop"]
[connection signal="state_physics_processing" from="StateChart/Root/Moving" to="." method="_apply_gravity"] [connection signal="state_physics_processing" from="StateChart/Root/Moving" to="." method="_apply_gravity"]
[connection signal="state_physics_processing" from="StateChart/Root/Moving" to="." method="_slow_to_stop"]
[connection signal="state_physics_processing" from="StateChart/Root/Moving" to="." method="_bounce_on_walls"]
[connection signal="state_entered" from="StateChart/Root/Charging" to="." method="_start_charge"] [connection signal="state_entered" from="StateChart/Root/Charging" to="." method="_start_charge"]
[connection signal="state_entered" from="StateChart/Root/Charging" to="Sounds/ChargeStart" method="play"] [connection signal="state_entered" from="StateChart/Root/Charging" to="Sounds/ChargeStart" method="play"]
[connection signal="state_exited" from="StateChart/Root/Charging" to="." method="_end_charge"] [connection signal="state_exited" from="StateChart/Root/Charging" to="." method="_end_charge"]