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:
_pole_stored_speed = flatten_vector(velocity).length()
velocity = Vector3.ZERO
floor_snap_length = 0.0
var pole_xz = flatten_vector(_attached_pole.global_position)
var self_xz = flatten_vector(global_position)
_pole_angle = Vector3.FORWARD.angle_to(self_xz - pole_xz)
func _process_pole_spin(delta: float) -> void:
var speed_factor = inverse_lerp(0.0, power_scale, _pole_stored_speed)
# 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,
_attached_pole.global_position.y,
@ -182,7 +184,7 @@ func _process_pole_spin(delta: float) -> void:
)
# 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 self_dir = Vector3.FORWARD.rotated(Vector3.UP, _pole_angle)
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
velocity.x = impulse.x
velocity.z = impulse.z
floor_snap_length = 0.1
#endregion