Dino sounds, wall gate

This commit is contained in:
karl 2019-11-24 15:39:05 +01:00
parent 3b02af205a
commit e1b188c4ca
6 changed files with 1232 additions and 48 deletions

View File

@ -3,8 +3,13 @@ extends KinematicBody
export(NodePath) var player_path export(NodePath) var player_path
export(float) var speed export(float) var speed
onready var growl_sound = get_node("GrowlSound")
onready var confuse_sound = get_node("ConfuseSound")
onready var see_sound = get_node("SeeSound")
var _current_nav_path: PoolVector3Array var _current_nav_path: PoolVector3Array
var _player var _player
var _had_path_in_previous_frame = false
onready var _navigation = get_parent() onready var _navigation = get_parent()
@ -13,6 +18,14 @@ func _ready():
_player = get_node(player_path) _player = get_node(player_path)
func _physics_process(delta: float) -> void:
# Play growling sound at random interval
var distance_to_player = (_player.transform.origin - transform.origin).length()
if randi() % 1000 == 1 and not _is_any_sound_playing():
growl_sound.play()
func _process(delta): func _process(delta):
var to = _navigation.get_closest_point(_player.transform.origin) var to = _navigation.get_closest_point(_player.transform.origin)
_current_nav_path = _navigation.get_simple_path(transform.origin, to) _current_nav_path = _navigation.get_simple_path(transform.origin, to)
@ -20,14 +33,27 @@ func _process(delta):
var dir: Vector3 var dir: Vector3
if _current_nav_path.size() > 0: if _current_nav_path.size() > 0:
if not _had_path_in_previous_frame and not _is_any_sound_playing():
see_sound.play()
var index = 0 var index = 0
if (_current_nav_path[0] - transform.origin).length() < 0.1: index = 1 if (_current_nav_path[0] - transform.origin).length() < 0.1: index = 1
dir = (_current_nav_path[index] - transform.origin).normalized() dir = (_current_nav_path[index] - transform.origin).normalized()
_had_path_in_previous_frame = true
else: else:
if _had_path_in_previous_frame and not _is_any_sound_playing():
confuse_sound.play()
dir = (_player.transform.origin - transform.origin).normalized() dir = (_player.transform.origin - transform.origin).normalized()
_had_path_in_previous_frame = false
if (dir.x != 0.0 and dir.z != 0.0): if (dir.x != 0.0 and dir.z != 0.0):
look_at(transform.origin + Vector3(dir.x, 0.0, dir.z), Vector3.UP) look_at(transform.origin + Vector3(dir.x, 0.0, dir.z), Vector3.UP)
move_and_slide(dir * speed) move_and_slide(dir * speed)
func _is_any_sound_playing():
return growl_sound.playing or confuse_sound.playing or see_sound.playing

View File

@ -1,6 +1,9 @@
[gd_scene load_steps=7 format=2] [gd_scene load_steps=10 format=2]
[ext_resource path="res://Enemies/Dino.gd" type="Script" id=1] [ext_resource path="res://Enemies/Dino.gd" type="Script" id=1]
[ext_resource path="res://Sounds/dino-roar-01.wav" type="AudioStream" id=2]
[ext_resource path="res://Sounds/dino-roar-02.wav" type="AudioStream" id=3]
[ext_resource path="res://Sounds/dino-roar-03.wav" type="AudioStream" id=4]
[sub_resource type="CapsuleShape" id=1] [sub_resource type="CapsuleShape" id=1]
radius = 5.0 radius = 5.0
@ -54,3 +57,21 @@ shape = SubResource( 4 )
[node name="CollisionShape" type="CollisionShape" parent="Area"] [node name="CollisionShape" type="CollisionShape" parent="Area"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 5, -4 ) transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 5, -4 )
shape = SubResource( 5 ) shape = SubResource( 5 )
[node name="GrowlSound" type="AudioStreamPlayer3D" parent="."]
transform = Transform( 1, 0, 0, 0, 0.906308, 0.422618, 0, -0.422618, 0.906308, 0, 12.6212, -8.63737 )
stream = ExtResource( 2 )
unit_size = 30.0
emission_angle_enabled = true
[node name="ConfuseSound" type="AudioStreamPlayer3D" parent="."]
transform = Transform( 1, 0, 0, 0, 0.906308, 0.422618, 0, -0.422618, 0.906308, 0, 12.6212, -8.63737 )
stream = ExtResource( 3 )
unit_size = 30.0
emission_angle_enabled = true
[node name="SeeSound" type="AudioStreamPlayer3D" parent="."]
transform = Transform( 1, 0, 0, 0, 0.906308, 0.422618, 0, -0.422618, 0.906308, 0, 12.6212, -8.63737 )
stream = ExtResource( 4 )
unit_size = 30.0
emission_angle_enabled = true

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

BIN
WikiJam/Models/WallGate.glb Normal file

Binary file not shown.

File diff suppressed because it is too large Load Diff