Skip to content

Commit

Permalink
Addon version
Browse files Browse the repository at this point in the history
  • Loading branch information
scriptsengineer committed Sep 19, 2023
1 parent 5e63a0b commit e041b98
Show file tree
Hide file tree
Showing 117 changed files with 2,085 additions and 0 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[gd_resource type="Resource" script_class="AudioInteract" load_steps=6 format=3 uid="uid://boafje76qrf27"]

[ext_resource type="Script" path="res://addons/character-controller/example/main/audios/audio_interact.gd" id="1_h7qps"]
[ext_resource type="AudioStream" uid="uid://dyj8811150sq5" path="res://addons/character-controller/example/main/jute-dh-steps/stepdirt_1.wav" id="1_sbipl"]
[ext_resource type="AudioStream" uid="uid://c2cl56b4rns2u" path="res://addons/character-controller/example/main/jute-dh-steps/stepdirt_2.wav" id="2_3lu1q"]
[ext_resource type="AudioStream" uid="uid://7gjj4wse1p7s" path="res://addons/character-controller/example/main/jute-dh-steps/stepdirt_3.wav" id="4_lhtnd"]
[ext_resource type="AudioStream" uid="uid://p8tdym4d3gwm" path="res://addons/character-controller/example/main/jute-dh-steps/stepdirt_4.wav" id="5_aklp5"]

[resource]
script = ExtResource("1_h7qps")
jump_audio = ExtResource("1_sbipl")
landed_audio = ExtResource("2_3lu1q")
step_audios = Array[AudioStream]([ExtResource("1_sbipl"), ExtResource("2_3lu1q"), ExtResource("4_lhtnd"), ExtResource("5_aklp5")])
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[gd_resource type="Resource" script_class="AudioInteract" load_steps=6 format=3 uid="uid://ci8kg40ae4vnl"]

[ext_resource type="Script" path="res://addons/character-controller/example/main/audios/audio_interact.gd" id="1_h7qps"]
[ext_resource type="AudioStream" uid="uid://ds7ryp7lrjkbk" path="res://addons/character-controller/example/main/jute-dh-steps/stepstone_8.wav" id="1_r63y8"]
[ext_resource type="AudioStream" uid="uid://dygk2exfcwaxj" path="res://addons/character-controller/example/main/jute-dh-steps/stepstone_7.wav" id="2_hgal4"]
[ext_resource type="AudioStream" uid="uid://d1824xmt02a32" path="res://addons/character-controller/example/main/jute-dh-steps/stepstone_1.wav" id="4_ec8je"]
[ext_resource type="AudioStream" uid="uid://cxycqe7hdav7o" path="res://addons/character-controller/example/main/jute-dh-steps/stepstone_2.wav" id="5_b6xfx"]

[resource]
script = ExtResource("1_h7qps")
jump_audio = ExtResource("1_r63y8")
landed_audio = ExtResource("2_hgal4")
step_audios = Array[AudioStream]([ExtResource("4_ec8je"), ExtResource("5_b6xfx")])
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[gd_resource type="Resource" script_class="AudioInteract" load_steps=4 format=3 uid="uid://clro80qf2tdqi"]

[ext_resource type="AudioStream" uid="uid://btyn2jp6i5s8l" path="res://addons/character-controller/example/main/jute-dh-steps/stepwater_1.wav" id="1_bqhqy"]
[ext_resource type="Script" path="res://addons/character-controller/example/main/audios/audio_interact.gd" id="1_h7qps"]
[ext_resource type="AudioStream" uid="uid://b3me04d8q11xf" path="res://addons/character-controller/example/main/jute-dh-steps/stepwater_2.wav" id="2_d8xo7"]

[resource]
script = ExtResource("1_h7qps")
jump_audio = ExtResource("1_bqhqy")
landed_audio = ExtResource("2_d8xo7")
step_audios = Array[AudioStream]([ExtResource("1_bqhqy"), ExtResource("2_d8xo7")])
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[gd_resource type="Resource" script_class="AudioInteract" load_steps=4 format=3 uid="uid://dx5kojv0cn4yl"]

[ext_resource type="AudioStream" uid="uid://bfsapqnlf7can" path="res://addons/character-controller/example/main/jute-dh-steps/stepwood_1.wav" id="1_0irbh"]
[ext_resource type="Script" path="res://addons/character-controller/example/main/audios/audio_interact.gd" id="1_h7qps"]
[ext_resource type="AudioStream" uid="uid://c7fdqytdjvcqe" path="res://addons/character-controller/example/main/jute-dh-steps/stepwood_2.wav" id="2_203mn"]

[resource]
script = ExtResource("1_h7qps")
jump_audio = ExtResource("1_0irbh")
landed_audio = ExtResource("2_203mn")
step_audios = Array[AudioStream]([ExtResource("1_0irbh"), ExtResource("2_203mn")])
18 changes: 18 additions & 0 deletions addons/character-controller/example/main/audios/audio_interact.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
extends Resource
class_name AudioInteract

## Resource that stores data by controller actions.

## Jump Audio
@export var jump_audio : AudioStream

## Landed Audio
@export var landed_audio : AudioStream

## Step Audios
@export var step_audios: Array[AudioStream]


## Get random step audio from list
func random_step() -> AudioStream:
return step_audios[randi() % step_audios.size()]
41 changes: 41 additions & 0 deletions addons/character-controller/example/main/audios/player_audios.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
[gd_scene load_steps=10 format=3]

[ext_resource type="Script" path="res://addons/character-controller/example/main/audios/player_audios_3d.gd" id="1_5jhob"]
[ext_resource type="Resource" uid="uid://boafje76qrf27" path="res://addons/character-controller/example/main/audio_interacts/grass_audio_interact.tres" id="2_m88gv"]
[ext_resource type="PhysicsMaterial" path="res://addons/character-controller/example/main/physics/grass.tres" id="3_pjbyl"]
[ext_resource type="PhysicsMaterial" uid="uid://bklf2cx3fydt3" path="res://addons/character-controller/example/main/physics/stone.tres" id="4_qrhb1"]
[ext_resource type="Resource" uid="uid://ci8kg40ae4vnl" path="res://addons/character-controller/example/main/audio_interacts/stone_audio_interact.tres" id="5_fv0qi"]
[ext_resource type="PhysicsMaterial" path="res://addons/character-controller/example/main/physics/wood.tres" id="5_vfwfh"]
[ext_resource type="Resource" uid="uid://clro80qf2tdqi" path="res://addons/character-controller/example/main/audio_interacts/water_audio_interact.tres" id="6_fohsf"]
[ext_resource type="Resource" uid="uid://dx5kojv0cn4yl" path="res://addons/character-controller/example/main/audio_interacts/wood_audio_interact.tres" id="7_483qj"]
[ext_resource type="AudioStream" uid="uid://dyj8811150sq5" path="res://addons/character-controller/example/main/jute-dh-steps/stepdirt_1.wav" id="9_pghw8"]

[node name="Player Audios" type="Node3D"]
script = ExtResource("1_5jhob")
audio_interact = ExtResource("2_m88gv")
physic_materials = [ExtResource("3_pjbyl"), ExtResource("4_qrhb1"), ExtResource("5_vfwfh")]
audio_interacts = [ExtResource("2_m88gv"), ExtResource("5_fv0qi"), ExtResource("7_483qj")]
water_audio_interact = ExtResource("6_fohsf")

[node name="Jump" type="AudioStreamPlayer3D" parent="."]
stream = ExtResource("9_pghw8")
attenuation_filter_db = -65.4

[node name="Step" type="AudioStreamPlayer3D" parent="."]
stream = ExtResource("9_pghw8")
attenuation_filter_db = -65.4

[node name="Land" type="AudioStreamPlayer3D" parent="."]
stream = ExtResource("9_pghw8")
attenuation_filter_db = -65.4

[node name="Crouch" type="AudioStreamPlayer3D" parent="."]
stream = ExtResource("9_pghw8")
attenuation_filter_db = -65.4

[node name="Uncrouch" type="AudioStreamPlayer3D" parent="."]
stream = ExtResource("9_pghw8")
attenuation_filter_db = -65.4

[node name="Detect Ground" type="RayCast3D" parent="."]
target_position = Vector3(0, -1.5, 0)
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
extends Node3D
class_name PlayerAudios3D

## Script that plays sounds based on player actions.
## Using an [AudioInteract] array synchronized with physic_materials array to
## identify different sound structures for each type of physical material.

@onready var step_stream: AudioStreamPlayer3D = get_node(NodePath("Step"))
@onready var land_stream: AudioStreamPlayer3D = get_node(NodePath("Land"))
@onready var jump_stream: AudioStreamPlayer3D = get_node(NodePath("Jump"))
@onready var crouch_stream: AudioStreamPlayer3D = get_node(NodePath("Crouch"))
@onready var uncrouch_stream: AudioStreamPlayer3D = get_node(NodePath("Uncrouch"))
@onready var raycast: RayCast3D = get_node(NodePath("Detect Ground"))
@onready var character_body: CharacterBody3D = get_node(NodePath(".."))
@onready var character_controller: CharacterController3D = get_node(NodePath(".."))

## Default audio interact used
@export var audio_interact : Resource

## List of [PhysicsMaterial] synchronized with the [AudioInteract] list
@export var physic_materials : Array[PhysicsMaterial]

## List of [AudioInteract] synchronized with the [PhysicsMaterial] list
@export var audio_interacts : Array[Resource]

## Specific case of audio interact that occurs when we are in the water
@export var water_audio_interact : Resource

func _ready():
pass
character_controller.stepped.connect(_on_controller_stepped.bind())
character_controller.crouched.connect(_on_controller_crouched.bind())
character_controller.jumped.connect(_on_controller_jumped.bind())
character_controller.landed.connect(_on_controller_landed.bind())
character_controller.uncrouched.connect(_on_controller_uncrouched.bind())
character_controller.entered_the_water.connect(_on_controller_entered_the_water.bind())
character_controller.exit_the_water.connect(_on_controller_exit_the_water.bind())

func _on_controller_jumped():
jump_stream.stream = audio_interact.jump_audio
jump_stream.play()


func _on_controller_landed():
_get_audio_interact()
land_stream.stream = audio_interact.landed_audio
land_stream.play()


func _on_controller_stepped():
var collision = raycast.get_collider()
_get_audio_interact_of_object(collision)
step_stream.stream = audio_interact.random_step()
step_stream.play()


func _get_audio_interact():
var k_col = character_body.get_last_slide_collision()
var collision = k_col.get_collider(0)
_get_audio_interact_of_object(collision)


func _get_audio_interact_of_object(collision):
if character_controller.is_on_water():
audio_interact = water_audio_interact
return
if !collision:
return
if not "physics_material_override" in collision:
return
var mat = collision.physics_material_override
if mat:
var i = physic_materials.rfind(mat)
if i != -1:
audio_interact = audio_interacts[i]


func _on_controller_crouched():
crouch_stream.play()


func _on_controller_uncrouched():
uncrouch_stream.play()


func _on_controller_entered_the_water():
audio_interact = water_audio_interact
land_stream.stream = audio_interact.landed_audio
land_stream.play()


func _on_controller_exit_the_water():
jump_stream.stream = audio_interact.jump_audio
jump_stream.play()
18 changes: 18 additions & 0 deletions addons/character-controller/example/main/geometry/floor.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[gd_scene load_steps=5 format=3 uid="uid://b3wdcta6c4k4t"]

[ext_resource type="Material" uid="uid://2ciy11rdndma" path="res://addons/character-controller/example/main/materials/grass.tres" id="1_sl4h5"]
[ext_resource type="PhysicsMaterial" path="res://addons/character-controller/example/main/physics/grass.tres" id="2_3we8r"]

[sub_resource type="BoxMesh" id="BoxMesh_srxwf"]

[sub_resource type="BoxShape3D" id="BoxShape3D_kxdy3"]

[node name="Floor" type="MeshInstance3D"]
mesh = SubResource("BoxMesh_srxwf")
surface_material_override/0 = ExtResource("1_sl4h5")

[node name="StaticBody3D" type="StaticBody3D" parent="."]
physics_material_override = ExtResource("2_3we8r")

[node name="CollisionShape3D" type="CollisionShape3D" parent="StaticBody3D"]
shape = SubResource("BoxShape3D_kxdy3")
18 changes: 18 additions & 0 deletions addons/character-controller/example/main/geometry/wall.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[gd_scene load_steps=4 format=3 uid="uid://cbfe8rkt51tf8"]

[ext_resource type="Material" uid="uid://ckvcdcn2iue87" path="res://addons/character-controller/example/main/materials/wood.tres" id="1_7lrh3"]

[sub_resource type="BoxMesh" id="BoxMesh_7y6gq"]
size = Vector3(40, 12, 1)

[sub_resource type="ConcavePolygonShape3D" id="ConcavePolygonShape3D_y0tdx"]
data = PackedVector3Array(-20, 6, 0.5, 20, 6, 0.5, -20, -6, 0.5, 20, 6, 0.5, 20, -6, 0.5, -20, -6, 0.5, 20, 6, -0.5, -20, 6, -0.5, 20, -6, -0.5, -20, 6, -0.5, -20, -6, -0.5, 20, -6, -0.5, 20, 6, 0.5, 20, 6, -0.5, 20, -6, 0.5, 20, 6, -0.5, 20, -6, -0.5, 20, -6, 0.5, -20, 6, -0.5, -20, 6, 0.5, -20, -6, -0.5, -20, 6, 0.5, -20, -6, 0.5, -20, -6, -0.5, 20, 6, 0.5, -20, 6, 0.5, 20, 6, -0.5, -20, 6, 0.5, -20, 6, -0.5, 20, 6, -0.5, -20, -6, 0.5, 20, -6, 0.5, -20, -6, -0.5, 20, -6, 0.5, 20, -6, -0.5, -20, -6, -0.5)

[node name="Wall" type="MeshInstance3D"]
mesh = SubResource("BoxMesh_7y6gq")
surface_material_override/0 = ExtResource("1_7lrh3")

[node name="StaticBody3D" type="StaticBody3D" parent="."]

[node name="CollisionShape3D" type="CollisionShape3D" parent="StaticBody3D"]
shape = SubResource("ConcavePolygonShape3D_y0tdx")
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[remap]

importer="wav"
type="AudioStreamWAV"
uid="uid://dyj8811150sq5"
path="res://.godot/imported/stepdirt_1.wav-86bd3faa52ae06e619ada6a4ca8c8e41.sample"

[deps]

source_file="res://addons/character-controller/example/main/jute-dh-steps/stepdirt_1.wav"
dest_files=["res://.godot/imported/stepdirt_1.wav-86bd3faa52ae06e619ada6a4ca8c8e41.sample"]

[params]

force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=false
edit/loop_mode=0
edit/loop_begin=0
edit/loop_end=-1
compress/mode=0
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[remap]

importer="wav"
type="AudioStreamWAV"
uid="uid://c2cl56b4rns2u"
path="res://.godot/imported/stepdirt_2.wav-64cc5f860cc80a97b5df8401ea1fc3ea.sample"

[deps]

source_file="res://addons/character-controller/example/main/jute-dh-steps/stepdirt_2.wav"
dest_files=["res://.godot/imported/stepdirt_2.wav-64cc5f860cc80a97b5df8401ea1fc3ea.sample"]

[params]

force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=false
edit/loop_mode=0
edit/loop_begin=0
edit/loop_end=-1
compress/mode=0
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[remap]

importer="wav"
type="AudioStreamWAV"
uid="uid://7gjj4wse1p7s"
path="res://.godot/imported/stepdirt_3.wav-e74a9c66f3c5a13b762c5af44280ced8.sample"

[deps]

source_file="res://addons/character-controller/example/main/jute-dh-steps/stepdirt_3.wav"
dest_files=["res://.godot/imported/stepdirt_3.wav-e74a9c66f3c5a13b762c5af44280ced8.sample"]

[params]

force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=false
edit/loop_mode=0
edit/loop_begin=0
edit/loop_end=-1
compress/mode=0
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[remap]

importer="wav"
type="AudioStreamWAV"
uid="uid://p8tdym4d3gwm"
path="res://.godot/imported/stepdirt_4.wav-4192cfd047f50eb8b6a54569e2a2c9d0.sample"

[deps]

source_file="res://addons/character-controller/example/main/jute-dh-steps/stepdirt_4.wav"
dest_files=["res://.godot/imported/stepdirt_4.wav-4192cfd047f50eb8b6a54569e2a2c9d0.sample"]

[params]

force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=false
edit/loop_mode=0
edit/loop_begin=0
edit/loop_end=-1
compress/mode=0
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[remap]

importer="wav"
type="AudioStreamWAV"
uid="uid://b6cfvl2uik7t1"
path="res://.godot/imported/stepdirt_5.wav-dedd5008291a67875d37c51c4e7414fb.sample"

[deps]

source_file="res://addons/character-controller/example/main/jute-dh-steps/stepdirt_5.wav"
dest_files=["res://.godot/imported/stepdirt_5.wav-dedd5008291a67875d37c51c4e7414fb.sample"]

[params]

force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=false
edit/loop_mode=0
edit/loop_begin=0
edit/loop_end=-1
compress/mode=0
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[remap]

importer="wav"
type="AudioStreamWAV"
uid="uid://b2mpyratvtim0"
path="res://.godot/imported/stepdirt_6.wav-4c5d05c44bba461f4950ee70ac5561ac.sample"

[deps]

source_file="res://addons/character-controller/example/main/jute-dh-steps/stepdirt_6.wav"
dest_files=["res://.godot/imported/stepdirt_6.wav-4c5d05c44bba461f4950ee70ac5561ac.sample"]

[params]

force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=false
edit/loop_mode=0
edit/loop_begin=0
edit/loop_end=-1
compress/mode=0
Binary file not shown.
Loading

0 comments on commit e041b98

Please sign in to comment.