[gd_scene load_steps=8 format=2] [ext_resource path="res://Breadmouth/breadmouth_1_tex.png" type="Texture" id=1] [ext_resource path="res://Breadmouth/breadmouth_1.obj" type="ArrayMesh" id=2] [ext_resource path="res://Breadmouth/Breadmouth-Gurgle.mp3" type="AudioStream" id=4] [ext_resource path="res://Breadmouth/Breadmouth-Slime.mp3" type="AudioStream" id=5] [sub_resource type="GDScript" id=1] script/source = "extends KinematicBody enum states {patrol, hunt} var path = [] var path_node = 0 var speed = 15 var total_time = 0 var state = states.patrol onready var nav = get_parent() onready var player = $\"../../Player\" onready var wander = $\"../../Path/PathFollow/Wander\" onready var visioncone = $CollisionShape func _ready(): pass func _process(_delta): pass func _physics_process(delta): if path_node < path.size(): var direction = (path[path_node] - global_transform.origin) if direction.length() < 1: path_node +=1 else: var target_position = path[path_node] var new_transform = transform.looking_at(target_position, Vector3.UP) transform = transform.interpolate_with(new_transform, 5 * delta) move_and_slide(direction.normalized() * ((cos(total_time)+1)*7), Vector3.UP) total_time += delta*2 func move_to(target_pos): path = nav.get_simple_path(global_transform.origin, target_pos) path_node = 0 func _on_Timer_timeout(): if state == states.hunt: move_to(player.global_transform.origin) elif state == states.patrol: move_to(wander.global_transform.origin) func _on_Gurgletimer_timeout(): $AudioStreamPlayer3D2.play(0.0) func _on_Detection_body_entered(_body): state = states.hunt func _on_Detection_body_exited(_body): state = states.patrol " [sub_resource type="SpatialMaterial" id=2] albedo_texture = ExtResource( 1 ) [sub_resource type="BoxShape" id=3] extents = Vector3( 3.5, 2, 7 ) [node name="Breadmouth" type="KinematicBody" groups=[ "Breadmouth", ]] collision_layer = 2 collision_mask = 0 script = SubResource( 1 ) [node name="CSGMesh" type="CSGMesh" parent="."] transform = Transform( -1.31134e-07, 0, 2, 0, 2, 0, -3, 0, -8.74228e-08, 0, 0, 0 ) mesh = ExtResource( 2 ) material = SubResource( 2 ) [node name="CollisionShape" type="CollisionShape" parent="."] transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2, 0 ) shape = SubResource( 3 ) [node name="Timer" type="Timer" parent="."] wait_time = 2.0 autostart = true [node name="AudioStreamPlayer3D" type="AudioStreamPlayer3D" parent="."] stream = ExtResource( 5 ) unit_db = 20.0 unit_size = 10.0 max_db = 5.0 autoplay = true max_distance = 50.0 [node name="AudioStreamPlayer3D2" type="AudioStreamPlayer3D" parent="."] stream = ExtResource( 4 ) unit_db = 10.0 max_db = 6.0 pitch_scale = 0.4 autoplay = true [node name="Gurgle-timer" type="Timer" parent="."] wait_time = 12.0 autostart = true [node name="Detection" type="Area" parent="."] monitorable = false [node name="CollisionPolygon" type="CollisionPolygon" parent="Detection"] transform = Transform( 0.5, 0, 0, 0, -3.49691e-08, -0.8, 0, 0.8, -3.49691e-08, 0, 2, 0 ) polygon = PoolVector2Array( -0.487793, -48.1692, -24.3895, -39.6329, -31.9502, -24.2675, -23.9017, 0.365844, -9.26801, 15.7312, 7.80463, 15.7312, 23.6578, -0.365842, 32.438, -23.5359, 23.9017, -40.1207 ) [connection signal="timeout" from="Timer" to="." method="_on_Timer_timeout"] [connection signal="timeout" from="Gurgle-timer" to="." method="_on_Gurgletimer_timeout"] [connection signal="body_entered" from="Detection" to="." method="_on_Detection_body_entered"] [connection signal="body_exited" from="Detection" to="." method="_on_Detection_body_exited"]