add player sounds
This commit is contained in:
parent
26deb746e7
commit
9fb4d38e05
2 changed files with 37 additions and 11 deletions
|
@ -1,6 +1,12 @@
|
|||
class_name Player
|
||||
extends CharacterBody3D
|
||||
|
||||
|
||||
signal bounced()
|
||||
signal shot()
|
||||
signal charge_canceled()
|
||||
|
||||
|
||||
@export_group("Visuals")
|
||||
@export var goal_animation_time: float = 1.0
|
||||
@export var charge_gradient: Gradient
|
||||
|
@ -96,6 +102,9 @@ func _end_charge() -> void:
|
|||
velocity = -camera_z.normalized() * power * power_scale
|
||||
prev_velocity = velocity
|
||||
_bounce_on_walls(1.0/60.0)
|
||||
shot.emit()
|
||||
else:
|
||||
charge_canceled.emit()
|
||||
#endregion
|
||||
|
||||
|
||||
|
@ -126,16 +135,7 @@ func _bounce_on_walls(delta: float = 0.0) -> void:
|
|||
h_vel = h_vel.bounce(col.get_normal())
|
||||
velocity.x = h_vel.x
|
||||
velocity.z = h_vel.z
|
||||
|
||||
#var h_vel = (prev_velocity * Vector3(1.0, 0.0, 1.0))
|
||||
#if not h_vel.is_zero_approx():
|
||||
#wall_detector.look_at(wall_detector.global_position - h_vel)
|
||||
#wall_detector.force_shapecast_update()
|
||||
#if wall_detector.is_colliding():
|
||||
#for i in wall_detector.get_collision_count():
|
||||
#h_vel = h_vel.bounce(wall_detector.get_collision_normal(i))
|
||||
#velocity.x = h_vel.x
|
||||
#velocity.z = h_vel.z
|
||||
bounced.emit()
|
||||
#endregion
|
||||
|
||||
|
||||
|
|
|
@ -1,11 +1,15 @@
|
|||
[gd_scene load_steps=15 format=3 uid="uid://cybm74xwbsivx"]
|
||||
[gd_scene load_steps=19 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"]
|
||||
[ext_resource type="Texture2D" uid="uid://bqg7vd5r7w8tm" path="res://assets/textures/shadow.png" id="2_fwt6m"]
|
||||
[ext_resource type="AudioStream" uid="uid://7u8a6osl4buo" path="res://assets/sounds/player/grab.ogg" id="4_hojxu"]
|
||||
[ext_resource type="Script" path="res://addons/godot_state_charts/state_chart.gd" id="4_n67yk"]
|
||||
[ext_resource type="Script" path="res://addons/godot_state_charts/compound_state.gd" id="5_ox6hb"]
|
||||
[ext_resource type="AudioStream" uid="uid://dis5fg68ese7r" path="res://assets/sounds/player/cancel.ogg" id="5_v6u4q"]
|
||||
[ext_resource type="AudioStream" uid="uid://dnyjfcq8m2r4f" path="res://assets/sounds/player/hit.ogg" id="6_a7neg"]
|
||||
[ext_resource type="Script" path="res://addons/godot_state_charts/atomic_state.gd" id="6_bu01i"]
|
||||
[ext_resource type="AudioStream" uid="uid://bv4plfa1oj3tf" path="res://assets/sounds/player/wall_bump.ogg" id="7_8ee3y"]
|
||||
[ext_resource type="Script" path="res://addons/godot_state_charts/transition.gd" id="7_epv8h"]
|
||||
[ext_resource type="Script" path="res://addons/godot_state_charts/expression_guard.gd" id="8_d5slg"]
|
||||
|
||||
|
@ -87,6 +91,24 @@ spring_length = 100.0
|
|||
pixel_size = 0.0313
|
||||
texture = ExtResource("2_fwt6m")
|
||||
|
||||
[node name="Sounds" type="Node3D" parent="."]
|
||||
|
||||
[node name="ChargeStart" type="AudioStreamPlayer3D" parent="Sounds"]
|
||||
stream = ExtResource("4_hojxu")
|
||||
bus = &"Sounds"
|
||||
|
||||
[node name="ChargeCancel" type="AudioStreamPlayer3D" parent="Sounds"]
|
||||
stream = ExtResource("5_v6u4q")
|
||||
bus = &"Sounds"
|
||||
|
||||
[node name="Shoot" type="AudioStreamPlayer3D" parent="Sounds"]
|
||||
stream = ExtResource("6_a7neg")
|
||||
bus = &"Sounds"
|
||||
|
||||
[node name="WallBounce" type="AudioStreamPlayer3D" parent="Sounds"]
|
||||
stream = ExtResource("7_8ee3y")
|
||||
bus = &"Sounds"
|
||||
|
||||
[node name="PowerIndicator" type="Node3D" parent="."]
|
||||
visible = false
|
||||
|
||||
|
@ -157,11 +179,15 @@ delay_in_seconds = "0.0"
|
|||
[node name="Winning" type="Node" parent="StateChart/Root"]
|
||||
script = ExtResource("6_bu01i")
|
||||
|
||||
[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_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"]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue