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
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=19 format=3 uid="uid://cybm74xwbsivx"]
|
||||
[gd_scene load_steps=20 format=3 uid="uid://cybm74xwbsivx"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://3i17aqnrspma" path="res://assets/textures/player/canny.png" id="1_cp4br"]
|
||||
[ext_resource type="Script" path="res://objects/canny_cat.gd" id="1_twfq8"]
|
||||
|
@ -26,6 +26,16 @@ albedo_color = Color(0.916968, 0.113727, 0, 1)
|
|||
[sub_resource type="SphereShape3D" id="SphereShape3D_4o01j"]
|
||||
radius = 0.9
|
||||
|
||||
[sub_resource type="AudioStreamInteractive" id="AudioStreamInteractive_plnjn"]
|
||||
clip_count = 3
|
||||
clip_0/name = &""
|
||||
clip_0/auto_advance = 0
|
||||
clip_1/name = &""
|
||||
clip_1/auto_advance = 1
|
||||
clip_1/next_clip = 0
|
||||
clip_2/name = &""
|
||||
clip_2/auto_advance = 0
|
||||
|
||||
[sub_resource type="CylinderMesh" id="CylinderMesh_b16dl"]
|
||||
top_radius = 0.05
|
||||
bottom_radius = 0.05
|
||||
|
@ -101,6 +111,10 @@ bus = &"Sounds"
|
|||
stream = ExtResource("5_v6u4q")
|
||||
bus = &"Sounds"
|
||||
|
||||
[node name="ChargeCancel2" type="AudioStreamPlayer3D" parent="Sounds"]
|
||||
stream = SubResource("AudioStreamInteractive_plnjn")
|
||||
bus = &"Sounds"
|
||||
|
||||
[node name="Shoot" type="AudioStreamPlayer3D" parent="Sounds"]
|
||||
stream = ExtResource("6_a7neg")
|
||||
bus = &"Sounds"
|
||||
|
@ -143,6 +157,12 @@ to = NodePath("../Winning")
|
|||
event = &"goal_entered"
|
||||
delay_in_seconds = "0.0"
|
||||
|
||||
[node name="on PoleAttached" type="Node" parent="StateChart/Root"]
|
||||
script = ExtResource("7_epv8h")
|
||||
to = NodePath("../PoleSpinning")
|
||||
event = &"pole_attached"
|
||||
delay_in_seconds = "0.0"
|
||||
|
||||
[node name="Idle" type="Node" parent="StateChart/Root"]
|
||||
script = ExtResource("6_bu01i")
|
||||
|
||||
|
@ -179,15 +199,27 @@ delay_in_seconds = "0.0"
|
|||
[node name="Winning" type="Node" parent="StateChart/Root"]
|
||||
script = ExtResource("6_bu01i")
|
||||
|
||||
[node name="PoleSpinning" type="Node" parent="StateChart/Root"]
|
||||
script = ExtResource("6_bu01i")
|
||||
|
||||
[node name="Transition" type="Node" parent="StateChart/Root/PoleSpinning"]
|
||||
script = ExtResource("7_epv8h")
|
||||
to = NodePath("../../Moving")
|
||||
event = &"charge_pressed"
|
||||
delay_in_seconds = "0.0"
|
||||
|
||||
[connection signal="bounced" from="." to="Sounds/WallBounce" method="play"]
|
||||
[connection signal="charge_canceled" from="." to="Sounds/ChargeCancel" 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/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="_slow_to_stop"]
|
||||
[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_exited" from="StateChart/Root/Charging" to="." method="_end_charge"]
|
||||
[connection signal="state_physics_processing" from="StateChart/Root/Charging" to="." method="_update_charge"]
|
||||
[connection signal="state_entered" from="StateChart/Root/Winning" to="." method="_start_winning"]
|
||||
[connection signal="state_entered" from="StateChart/Root/PoleSpinning" to="." method="_start_pole_spin"]
|
||||
[connection signal="state_exited" from="StateChart/Root/PoleSpinning" to="." method="_end_pole_spin"]
|
||||
[connection signal="state_physics_processing" from="StateChart/Root/PoleSpinning" to="." method="_process_pole_spin"]
|
||||
|
|
17
objects/waterman_pole.gd
Normal file
17
objects/waterman_pole.gd
Normal file
|
@ -0,0 +1,17 @@
|
|||
class_name WatermanPole
|
||||
extends Node3D
|
||||
|
||||
|
||||
@export var rise_speed: float
|
||||
@export_range(-1,1,0.5,"or_less","or_greater","radians_as_degrees")
|
||||
var spin_speed: float
|
||||
@export var offset: float
|
||||
@export var release_boost: float
|
||||
|
||||
@export_group("Node References")
|
||||
@export var top: Node3D
|
||||
|
||||
|
||||
func _on_player_detector_body_entered(body: Node3D) -> void:
|
||||
if body is Player:
|
||||
body.attach_to_pole(self)
|
54
objects/waterman_pole.tscn
Normal file
54
objects/waterman_pole.tscn
Normal file
|
@ -0,0 +1,54 @@
|
|||
[gd_scene load_steps=6 format=3 uid="uid://13qlrib2dk36"]
|
||||
|
||||
[ext_resource type="Script" path="res://objects/waterman_pole.gd" id="1_8whes"]
|
||||
|
||||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_6xwjl"]
|
||||
shading_mode = 2
|
||||
specular_mode = 2
|
||||
albedo_color = Color(3.27289e-06, 0.685269, 0.929658, 1)
|
||||
metallic_specular = 0.0
|
||||
|
||||
[sub_resource type="CylinderMesh" id="CylinderMesh_nbwjg"]
|
||||
top_radius = 0.25
|
||||
bottom_radius = 0.25
|
||||
height = 1.0
|
||||
radial_segments = 6
|
||||
rings = 8
|
||||
|
||||
[sub_resource type="CylinderShape3D" id="CylinderShape3D_28fhu"]
|
||||
height = 1.0
|
||||
radius = 0.25
|
||||
|
||||
[sub_resource type="CylinderShape3D" id="CylinderShape3D_o6xmv"]
|
||||
height = 1.0
|
||||
radius = 0.4
|
||||
|
||||
[node name="WatermanPole" type="Node3D" node_paths=PackedStringArray("top")]
|
||||
script = ExtResource("1_8whes")
|
||||
top = NodePath("Top")
|
||||
|
||||
[node name="MeshInstance3D" type="MeshInstance3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.5, 0)
|
||||
material_override = SubResource("StandardMaterial3D_6xwjl")
|
||||
mesh = SubResource("CylinderMesh_nbwjg")
|
||||
|
||||
[node name="StaticBody3D" type="StaticBody3D" parent="."]
|
||||
collision_mask = 0
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="StaticBody3D"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.5, 0)
|
||||
shape = SubResource("CylinderShape3D_28fhu")
|
||||
|
||||
[node name="PlayerDetector" type="Area3D" parent="."]
|
||||
collision_layer = 0
|
||||
collision_mask = 16
|
||||
monitorable = false
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="PlayerDetector"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.5, 0)
|
||||
shape = SubResource("CylinderShape3D_o6xmv")
|
||||
|
||||
[node name="Top" type="Node3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0)
|
||||
|
||||
[connection signal="body_entered" from="PlayerDetector" to="." method="_on_player_detector_body_entered"]
|
Loading…
Add table
Add a link
Reference in a new issue