bony cronies

This commit is contained in:
Haze Weathers 2025-02-23 04:21:11 -05:00
parent b5ad55e70f
commit 4a7cc4c401
10 changed files with 143 additions and 1 deletions

35
objects/boney.gd Normal file
View file

@ -0,0 +1,35 @@
extends CharacterBody3D
@export var speed: float
@export_range(0,1,1,"or_less","or_greater","radians_as_degrees")
var rotation_speed: float
@export var death_delay: float
@export_group("Node References")
@export var model: Node3D
@export var death_sound: AudioStreamPlayer3D
func _ready() -> void:
velocity = global_basis.z * speed
rotation = Vector3.ZERO
func _physics_process(delta: float) -> void:
model.global_rotation.y = wrapf(Time.get_ticks_msec() * 0.001 * rotation_speed, 0.0, TAU)
var col = move_and_collide(velocity * delta)
if col:
if col.get_collider() is Player:
queue_free()
velocity = velocity.bounce(col.get_normal())
func _on_player_detector_body_entered(body: Node3D) -> void:
if body is Player:
model.visible = false
death_sound.play()
var tween = create_tween()
tween.set_process_mode(Tween.TWEEN_PROCESS_PHYSICS)
tween.tween_callback(queue_free).set_delay(death_delay)

45
objects/boney.tscn Normal file
View file

@ -0,0 +1,45 @@
[gd_scene load_steps=7 format=3 uid="uid://b4a8aif3iigdw"]
[ext_resource type="Script" path="res://objects/boney.gd" id="1_bofrm"]
[ext_resource type="PackedScene" uid="uid://46kyrtlb6b0a" path="res://assets/models/enemies/boney.glb" id="2_ssgky"]
[ext_resource type="AudioStream" uid="uid://cgotekctoej7m" path="res://assets/sounds/enemies/skull_death.ogg" id="3_a4a2f"]
[sub_resource type="CylinderShape3D" id="CylinderShape3D_ictao"]
height = 0.5
radius = 0.4
[sub_resource type="CylinderShape3D" id="CylinderShape3D_cdksx"]
height = 0.5
[sub_resource type="AudioStreamRandomizer" id="AudioStreamRandomizer_5d27a"]
random_pitch = 1.5
streams_count = 1
stream_0/stream = ExtResource("3_a4a2f")
[node name="Boney" type="CharacterBody3D" node_paths=PackedStringArray("model", "death_sound")]
script = ExtResource("1_bofrm")
death_delay = 0.2
model = NodePath("Model")
death_sound = NodePath("DeathSound")
[node name="Model" parent="." instance=ExtResource("2_ssgky")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.75, 0)
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.5, 0)
shape = SubResource("CylinderShape3D_ictao")
[node name="PlayerDetector" type="Area3D" parent="."]
collision_layer = 0
collision_mask = 16
monitorable = false
[node name="CollisionShape3D" type="CollisionShape3D" parent="PlayerDetector"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.5, 0)
shape = SubResource("CylinderShape3D_cdksx")
[node name="DeathSound" type="AudioStreamPlayer3D" parent="."]
stream = SubResource("AudioStreamRandomizer_5d27a")
bus = &"Sounds"
[connection signal="body_entered" from="PlayerDetector" to="." method="_on_player_detector_body_entered" flags=6]

View file

@ -158,9 +158,9 @@ delay_in_seconds = "0.0"
script = ExtResource("6_bu01i")
[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_physics_processing" from="StateChart/Root/Moving" to="." method="_bounce_on_walls"]
[connection signal="state_entered" from="StateChart/Root/Charging" to="." method="_start_charge"]
[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"]