initial work on waterman's pole
This commit is contained in:
parent
ffc1935570
commit
1a57d92326
5 changed files with 162 additions and 6 deletions
|
@ -43,9 +43,10 @@ var power: float = 0.0:
|
|||
var charging_power: bool = false
|
||||
var prev_velocity: Vector3 = Vector3.ZERO
|
||||
|
||||
var _entered_goal: Node3D = self
|
||||
var _entered_goal: Node3D = null
|
||||
|
||||
|
||||
#region Builtin Overrides
|
||||
func _ready() -> void:
|
||||
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
|
||||
|
||||
|
@ -70,12 +71,18 @@ func _unhandled_input(event: InputEvent) -> void:
|
|||
else:
|
||||
camera_arm.rotation.x -= event.screen_relative.y * camera_pitch_sensitivity
|
||||
camera_arm.rotation.x = clampf(camera_arm.rotation.x, -camera_high_angle, -camera_low_angle)
|
||||
#endregion
|
||||
|
||||
|
||||
#region Public Functions
|
||||
func enter_goal(goal: GoalPost) -> void:
|
||||
_entered_goal = goal
|
||||
state_chart.send_event(&"goal_entered")
|
||||
|
||||
|
||||
func attach_to_pole(pole: WatermanPole) -> void:
|
||||
_attached_pole = pole
|
||||
state_chart.send_event(&"pole_attached")
|
||||
#endregion
|
||||
|
||||
|
||||
|
@ -151,3 +158,44 @@ func _start_winning() -> void:
|
|||
tween.set_parallel(true)
|
||||
tween.tween_property(graphics, ^"global_position", _entered_goal.global_position, goal_animation_time)
|
||||
#endregion
|
||||
|
||||
|
||||
#region Pole Spinning
|
||||
var _attached_pole: WatermanPole = null
|
||||
var _pole_angle: float = 0.0
|
||||
|
||||
func _start_pole_spin() -> void:
|
||||
velocity = Vector3.ZERO
|
||||
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:
|
||||
# rise
|
||||
global_position.y += _attached_pole.rise_speed * delta
|
||||
global_position.y = clampf(
|
||||
global_position.y,
|
||||
_attached_pole.global_position.y,
|
||||
_attached_pole.top.global_position.y
|
||||
)
|
||||
|
||||
# spin
|
||||
_pole_angle += _attached_pole.spin_speed * 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
|
||||
global_position.x = self_xz.x
|
||||
global_position.z = self_xz.z
|
||||
|
||||
func _end_pole_spin() -> void:
|
||||
var pole_xz = flatten_vector(_attached_pole.global_position)
|
||||
var impulse = Vector3.FORWARD.rotated(Vector3.UP, _pole_angle) * _attached_pole.release_boost
|
||||
velocity.x = impulse.x
|
||||
velocity.z = impulse.z
|
||||
#endregion
|
||||
|
||||
|
||||
#region Helpers
|
||||
func flatten_vector(vector: Vector3) -> Vector3:
|
||||
return Vector3(vector.x, 0.0, vector.z)
|
||||
#endregion
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue