Skip to content

Commit

Permalink
audio movement system
Browse files Browse the repository at this point in the history
created an audio movement system that moves audio players with player. currently only works on x axis.
  • Loading branch information
beefyjoe authored Feb 4, 2021
1 parent 7b12964 commit e231cfc
Show file tree
Hide file tree
Showing 15 changed files with 490 additions and 32 deletions.
Binary file added audio/loop_hum_06.ogg
Binary file not shown.
15 changes: 15 additions & 0 deletions audio/loop_hum_06.ogg.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[remap]

importer="ogg_vorbis"
type="AudioStreamOGGVorbis"
path="res://.import/loop_hum_06.ogg-4ee4e3c5fbacad68fc7d4d6620b735a6.oggstr"

[deps]

source_file="res://audio/loop_hum_06.ogg"
dest_files=[ "res://.import/loop_hum_06.ogg-4ee4e3c5fbacad68fc7d4d6620b735a6.oggstr" ]

[params]

loop=true
loop_offset=0
13 changes: 8 additions & 5 deletions entities/player/Player.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
[ext_resource path="res://entities/player/player_controller.gd" type="Script" id=1]

[sub_resource type="CapsuleShape" id=1]
radius = 0.6
height = 1.5
radius = 0.430359
height = 1.96055

[node name="Player" type="KinematicBody" groups=[
"Player",
Expand All @@ -16,13 +16,16 @@ head_path = NodePath("Head")
cam_path = NodePath("Head/Camera")

[node name="Collision" type="CollisionShape" parent="."]
transform = Transform( 1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, 0, 0 )
transform = Transform( 1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, 1.11964, 0 )
shape = SubResource( 1 )

[node name="Head" type="Spatial" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0 )
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.67877, 0 )

[node name="Camera" type="Camera" parent="Head"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.522507, 0 )
keep_aspect = 0
current = true
fov = 80.0
far = 250.0
near = 0.07
far = 74.4
40 changes: 15 additions & 25 deletions entities/player/player_controller.gd
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ var direction := Vector3()
var move_axis := Vector2()
var sprint_enabled := true
var sprinting := false
var position = self.get_translation()
var ypos = Vector3()
var fly = false
signal position(position)
# Walk
const FLOOR_MAX_ANGLE: float = deg2rad(46.0)
export(float) var gravity = 30.0
Expand All @@ -28,7 +32,6 @@ export(int) var jump_height = 10
# Fly
export(int) var fly_speed = 10
export(int) var fly_accel = 4
var flying := false

##################################################

Expand All @@ -46,11 +49,9 @@ func _process(_delta: float) -> void:

# Called every physics tick. 'delta' is constant
func _physics_process(delta: float) -> void:
if flying:
fly(delta)
else:
walk(delta)
walk(delta)

#print("current Pos: ", PosX, " | ", PosZ)

# Called when there is an input event
func _input(event: InputEvent) -> void:
Expand All @@ -73,14 +74,16 @@ func walk(delta: float) -> void:
direction += aim.x
direction.y = 0
direction = direction.normalized()
var position = self.get_translation()
emit_signal("position", position)

# Jump
var _snap: Vector3
if is_on_floor():
_snap = Vector3.DOWN
if Input.is_action_just_pressed("move_jump"):
_snap = Vector3.ZERO
velocity.y = jump_height
# if is_on_floor():
# _snap = Vector3.DOWN
# if Input.is_action_just_pressed("move_jump"):
# _snap = Vector3.ZERO
# velocity.y = jump_height

# Apply Gravity
velocity.y -= gravity * delta
Expand Down Expand Up @@ -126,21 +129,6 @@ func walk(delta: float) -> void:
velocity = moving
else:
velocity.y = moving.y


func fly(delta: float) -> void:
# Input
direction = Vector3()
var aim = head.get_global_transform().basis
if move_axis.x >= 0.5:
direction -= aim.z
if move_axis.x <= -0.5:
direction += aim.z
if move_axis.y <= -0.5:
direction -= aim.x
if move_axis.y >= 0.5:
direction += aim.x
direction = direction.normalized()

# Acceleration and Deacceleration
var target: Vector3 = direction * fly_speed
Expand Down Expand Up @@ -169,3 +157,5 @@ func camera_rotation() -> void:

func can_sprint() -> bool:
return (sprint_enabled and is_on_floor())


56 changes: 56 additions & 0 deletions room8.mtl
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Blender MTL File: 'None'
# Material Count: 5

newmtl Material.017
Ns 225.000000
Ka 1.000000 1.000000 1.000000
Kd 0.800000 0.800000 0.800000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.450000
d 1.000000
illum 2
map_Kd textures\\wall.png

newmtl Material.018
Ns 225.000000
Ka 1.000000 1.000000 1.000000
Kd 0.800000 0.800000 0.800000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.450000
d 1.000000
illum 2
map_Kd textures\\wall.png

newmtl Material.019
Ns 225.000000
Ka 1.000000 1.000000 1.000000
Kd 0.800000 0.800000 0.800000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.450000
d 1.000000
illum 2
map_Kd textures\\wall.png

newmtl Material.020
Ns 225.000000
Ka 1.000000 1.000000 1.000000
Kd 0.800000 0.800000 0.800000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.450000
d 1.000000
illum 2
map_Kd textures\\wall.png

newmtl None.004
Ns 500.000001
Ka 1.000000 1.000000 1.000000
Kd 0.800000 0.800000 0.800000
Ks 0.800000 0.800000 0.800000
Ke 0.000000 0.000000 0.000000
Ni 1.450000
d 1.000000
illum 2
202 changes: 202 additions & 0 deletions room8.obj
Original file line number Diff line number Diff line change
@@ -0,0 +1,202 @@
# Blender v2.91.2 OBJ File: ''
# www.blender.org
mtllib room8.mtl
o Plane.004
v -6.000000 -0.000001 6.000000
v 6.000000 -0.000001 6.000000
v 6.000000 0.000001 -6.000000
v -6.000000 0.000001 -6.000000
vt 0.000000 0.000000
vt 1.000000 0.000000
vt 1.000000 1.000000
vt 0.000000 1.000000
vn 0.0000 1.0000 0.0000
usemtl None.004
s 1
f 1/1/1 2/2/1 3/3/1 4/4/1
o Cube_Cube.005
v 5.470142 -0.169508 -5.468062
v 5.470142 6.240907 -5.468061
v 1.964962 6.240907 -5.468061
v 1.964962 -0.169508 -5.468062
v 6.002106 -0.169509 -2.040462
v 6.002106 6.240906 -2.040461
v 5.470142 6.240906 -2.040461
v 5.470142 -0.169509 -2.040462
v 1.964962 6.240907 -6.023550
v 1.964962 -0.169508 -6.023551
vt 0.901608 0.195992
vt 0.905529 0.976060
vt 0.029491 0.976060
vt 0.028030 0.198453
vt 0.526477 -0.225535
vt 0.529097 1.181019
vt 0.382474 1.185624
vt 0.379854 -0.220931
vt 1.159030 0.059093
vt 1.159079 1.135916
vt 0.404489 1.135976
vt 0.404440 0.059153
vt 0.002423 0.509524
vt 0.002426 -0.349936
vt 0.153912 -0.349936
vt 0.153910 0.509524
vn 0.0000 -0.0000 1.0000
vn -1.0000 -0.0000 0.0000
usemtl Material.017
s 1
f 5/5/2 6/6/2 7/7/2 8/8/2
f 9/9/2 10/10/2 11/11/2 12/12/2
f 12/13/3 11/14/3 6/15/3 5/16/3
f 8/17/3 7/18/3 13/19/3 14/20/3
o Cube.002_Cube.004
v 5.386618 -0.169510 5.524847
v 5.386618 6.240905 5.524848
v 5.441738 6.240905 2.020101
v 5.441738 -0.169509 2.020100
v 1.951077 -0.169510 6.002845
v 1.951077 6.240905 6.002846
v 1.959442 6.240905 5.470948
v 1.959442 -0.169510 5.470947
v 5.997159 6.240905 2.028837
v 5.997159 -0.169509 2.028836
vt 0.901608 0.195992
vt 0.905529 0.976060
vt 0.029491 0.976060
vt 0.028030 0.198453
vt 0.526477 -0.225535
vt 0.529097 1.181019
vt 0.382474 1.185624
vt 0.379854 -0.220931
vt 1.159030 0.059093
vt 1.159079 1.135916
vt 0.404489 1.135976
vt 0.404440 0.059153
vt 0.002423 0.509524
vt 0.002426 -0.349936
vt 0.153912 -0.349936
vt 0.153910 0.509524
vn -0.9999 -0.0000 -0.0157
vn 0.0157 0.0000 -0.9999
usemtl Material.018
s 1
f 15/21/4 16/22/4 17/23/4 18/24/4
f 19/25/4 20/26/4 21/27/4 22/28/4
f 22/29/5 21/30/5 16/31/5 15/32/5
f 18/33/5 17/34/5 23/35/5 24/36/5
o Cube.003_Cube.004
v -5.461724 -0.169510 5.442315
v -5.461724 6.240905 5.442316
v -1.956553 6.240905 5.450621
v -1.956553 -0.169510 5.450620
v -5.985565 -0.169509 2.013465
v -5.985565 6.240905 2.013466
v -5.453603 6.240905 2.014726
v -5.453603 -0.169509 2.014725
v -1.957869 6.240905 6.006108
v -1.957869 -0.169510 6.006107
vt 0.901608 0.195992
vt 0.905529 0.976060
vt 0.029491 0.976060
vt 0.028030 0.198453
vt 0.526477 -0.225535
vt 0.529097 1.181019
vt 0.382474 1.185624
vt 0.379854 -0.220931
vt 1.159030 0.059093
vt 1.159079 1.135916
vt 0.404489 1.135976
vt 0.404440 0.059153
vt 0.002423 0.509524
vt 0.002426 -0.349936
vt 0.153912 -0.349936
vt 0.153910 0.509524
vn 0.0024 0.0000 -1.0000
vn 1.0000 0.0000 0.0024
usemtl Material.019
s 1
f 25/37/6 26/38/6 27/39/6 28/40/6
f 29/41/6 30/42/6 31/43/6 32/44/6
f 32/45/7 31/46/7 26/47/7 25/48/7
f 28/49/7 27/50/7 33/51/7 34/52/7
o Cube.001_Cube.004
v -5.378401 -0.169508 -5.537739
v -5.378401 6.240907 -5.537738
v -5.441824 6.240906 -2.033132
v -5.441824 -0.169509 -2.033133
v -1.941738 -0.169508 -6.007596
v -1.941738 6.240907 -6.007595
v -1.951363 6.240907 -5.475719
v -1.951363 -0.169508 -5.475720
v -5.997222 6.240906 -2.043183
v -5.997222 -0.169509 -2.043184
vt 0.901608 0.195992
vt 0.905529 0.976060
vt 0.029491 0.976060
vt 0.028030 0.198453
vt 0.526477 -0.225535
vt 0.529097 1.181019
vt 0.382474 1.185624
vt 0.379854 -0.220931
vt 1.159030 0.059093
vt 1.159079 1.135916
vt 0.404489 1.135976
vt 0.404440 0.059153
vt 0.002423 0.509524
vt 0.002426 -0.349936
vt 0.153912 -0.349936
vt 0.153910 0.509524
vn 0.9998 0.0000 0.0181
vn -0.0181 -0.0000 0.9998
usemtl Material.020
s 1
f 35/53/8 36/54/8 37/55/8 38/56/8
f 39/57/8 40/58/8 41/59/8 42/60/8
f 42/61/9 41/62/9 36/63/9 35/64/9
f 38/65/9 37/66/9 43/67/9 44/68/9
o Cube.004_Cube.001
v -5.444204 -0.400866 2.013844
v -5.444204 6.224983 2.013845
v 5.465441 6.224983 2.013845
v 5.465441 -0.400866 2.013844
v 5.465441 -0.400866 2.508977
v 5.465441 6.224983 2.508978
v -5.444204 6.224983 2.508978
v -5.444204 -0.400866 2.508977
vt 3.257027 0.409433
vt 3.252763 2.223569
vt 0.243440 2.224055
vt 0.257004 0.409919
vt -1.201023 0.999689
vt -1.200402 -0.031609
vt 2.609196 -0.030988
vt 2.608574 1.000310
vn 0.0000 0.0000 -1.0000
vn 0.0000 -0.0000 1.0000
usemtl Material.017
s 1
f 45/69/10 46/70/10 47/71/10 48/72/10
f 49/73/11 50/74/11 51/75/11 52/76/11
o Cube.004_Cube.002_Cube.004_Cube.001
v -5.444204 -0.400866 -2.532493
v -5.444204 6.224983 -2.532492
v 5.465441 6.224983 -2.532492
v 5.465441 -0.400866 -2.532493
v 5.465441 -0.400866 -2.037360
v 5.465441 6.224983 -2.037359
v -5.444204 6.224983 -2.037359
v -5.444204 -0.400866 -2.037360
vt 3.257027 0.409433
vt 3.252763 2.223569
vt 0.243440 2.224055
vt 0.257004 0.409919
vt -1.201023 0.999689
vt -1.200402 -0.031609
vt 2.609196 -0.030988
vt 2.608574 1.000310
vn 0.0000 0.0000 -1.0000
vn 0.0000 -0.0000 1.0000
usemtl Material.017
s 1
f 53/77/12 54/78/12 55/79/12 56/80/12
f 57/81/13 58/82/13 59/83/13 60/84/13
Loading

0 comments on commit e231cfc

Please sign in to comment.