added breakable objects

This commit is contained in:
derek
2024-07-16 16:47:12 -05:00
parent afe19d8848
commit 262abd7d95
25 changed files with 2149 additions and 17 deletions

Binary file not shown.

View File

@@ -0,0 +1,24 @@
[remap]
importer="wav"
type="AudioStreamWAV"
uid="uid://cpno72fej708i"
path="res://.godot/imported/electric-chair-2-SBA-300021018.wav-1eb6dceb6417793ceb81ea9b7676b512.sample"
[deps]
source_file="res://assets/Audio/electric-chair-2-SBA-300021018.wav"
dest_files=["res://.godot/imported/electric-chair-2-SBA-300021018.wav-1eb6dceb6417793ceb81ea9b7676b512.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

View File

@@ -0,0 +1,24 @@
[remap]
importer="wav"
type="AudioStreamWAV"
uid="uid://bn4y63ws8jscs"
path="res://.godot/imported/glass-break-two-thick-glasses-SBA-300121605.wav-d20024f925b04fce74d522560050188e.sample"
[deps]
source_file="res://assets/Audio/glass-break-two-thick-glasses-SBA-300121605.wav"
dest_files=["res://.godot/imported/glass-break-two-thick-glasses-SBA-300121605.wav-d20024f925b04fce74d522560050188e.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.

BIN
assets/Models/bottle1.blend Normal file

Binary file not shown.

View File

@@ -0,0 +1,50 @@
[remap]
importer="scene"
importer_version=1
type="PackedScene"
uid="uid://cklopajsap1s8"
path="res://.godot/imported/bottle1.blend-92d087c5b3d44431c89ae3e329fe4160.scn"
[deps]
source_file="res://assets/Models/bottle1.blend"
dest_files=["res://.godot/imported/bottle1.blend-92d087c5b3d44431c89ae3e329fe4160.scn"]
[params]
nodes/root_type=""
nodes/root_name=""
nodes/apply_root_scale=true
nodes/root_scale=1.0
meshes/ensure_tangents=true
meshes/generate_lods=true
meshes/create_shadow_meshes=true
meshes/light_baking=1
meshes/lightmap_texel_size=0.2
meshes/force_disable_compression=false
skins/use_named_skins=true
animation/import=true
animation/fps=30
animation/trimming=false
animation/remove_immutable_tracks=true
import_script/path=""
_subresources={}
gltf/naming_version=1
gltf/embedded_image_handling=1
blender/nodes/visible=0
blender/nodes/punctual_lights=true
blender/nodes/cameras=true
blender/nodes/custom_properties=true
blender/nodes/modifiers=1
blender/meshes/colors=false
blender/meshes/uvs=true
blender/meshes/normals=true
blender/meshes/tangents=true
blender/meshes/skins=2
blender/meshes/export_bones_deforming_mesh_only=false
blender/materials/unpack_enabled=true
blender/materials/export_materials=1
blender/animation/limit_playback=true
blender/animation/always_sample=true
blender/animation/group_tracks=true

Binary file not shown.

View File

@@ -59,6 +59,8 @@ collision_layer = 4
collision_mask = 6 collision_mask = 6
script = ExtResource("1_sni3c") script = ExtResource("1_sni3c")
collision_shape = NodePath("CollisionShape3D2") collision_shape = NodePath("CollisionShape3D2")
despawning = true
despawn_time_s = 20
pickupType = "ammo" pickupType = "ammo"
[node name="Area3D" type="Area3D" parent="."] [node name="Area3D" type="Area3D" parent="."]

View File

@@ -1,6 +1,8 @@
[gd_scene load_steps=7 format=3 uid="uid://bpkmyd3wvqi5p"] [gd_scene load_steps=9 format=3 uid="uid://bpkmyd3wvqi5p"]
[ext_resource type="AudioStream" uid="uid://diwsk0cw41ep1" path="res://assets/Audio/Music/Test Songs/easy-walk-SBA-347061820.wav" id="1_0tv5a"] [ext_resource type="AudioStream" uid="uid://diwsk0cw41ep1" path="res://assets/Audio/Music/Test Songs/easy-walk-SBA-347061820.wav" id="1_0tv5a"]
[ext_resource type="Script" path="res://scripts/breakable.gd" id="1_dm2iv"]
[ext_resource type="PackedScene" uid="uid://ccnnxudjaptb4" path="res://assets/boombox_broken.tscn" id="2_26e0l"]
[sub_resource type="BoxShape3D" id="BoxShape3D_1swe3"] [sub_resource type="BoxShape3D" id="BoxShape3D_1swe3"]
size = Vector3(2.04077, 0.734375, 0.581665) size = Vector3(2.04077, 0.734375, 0.581665)
@@ -76,10 +78,12 @@ _surfaces = [{
blend_shape_mode = 0 blend_shape_mode = 0
shadow_mesh = SubResource("ArrayMesh_nxwjy") shadow_mesh = SubResource("ArrayMesh_nxwjy")
[node name="Boombox" type="RigidBody3D" groups=["scene_rigidbody"]] [node name="Boombox" type="RigidBody3D" groups=["breakable", "scene_rigidbody"]]
collision_layer = 2 collision_layer = 2
collision_mask = 7 collision_mask = 7
continuous_cd = true continuous_cd = true
script = ExtResource("1_dm2iv")
broken_object = ExtResource("2_26e0l")
[node name="CollisionShape3D" type="CollisionShape3D" parent="."] [node name="CollisionShape3D" type="CollisionShape3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.433783, 0.16095) transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.433783, 0.16095)

744
assets/boombox_broken.tscn Normal file

File diff suppressed because one or more lines are too long

60
assets/bottle_1.tscn Normal file

File diff suppressed because one or more lines are too long

267
assets/bottle_1_pieces.tscn Normal file

File diff suppressed because one or more lines are too long

View File

@@ -396,7 +396,7 @@ script = ExtResource("2_6i1l4")
gun_name = "Mac 10" gun_name = "Mac 10"
max_ammo = 30 max_ammo = 30
bullet_drop = 0.05 bullet_drop = 0.05
random_spread_amt = 1.5 random_spread_amt = 0.3
fire_pitch_scale_amt = 0.1 fire_pitch_scale_amt = 0.1
flare_light = NodePath("mac10/SpotLight3D") flare_light = NodePath("mac10/SpotLight3D")
bullet = ExtResource("3_pyl20") bullet = ExtResource("3_pyl20")
@@ -462,16 +462,17 @@ libraries = {
[node name="Fire" type="AudioStreamPlayer3D" parent="Audio" index="0"] [node name="Fire" type="AudioStreamPlayer3D" parent="Audio" index="0"]
stream = ExtResource("4_qynbq") stream = ExtResource("4_qynbq")
volume_db = 5.0 volume_db = 7.0
bus = &"SFX" bus = &"SFX"
[node name="Empty" type="AudioStreamPlayer3D" parent="Audio" index="1"] [node name="Empty" type="AudioStreamPlayer3D" parent="Audio" index="1"]
stream = ExtResource("5_rn7j1") stream = ExtResource("5_rn7j1")
volume_db = 4.0
bus = &"SFX" bus = &"SFX"
[node name="Reload" type="AudioStreamPlayer3D" parent="Audio" index="2"] [node name="Reload" type="AudioStreamPlayer3D" parent="Audio" index="2"]
stream = ExtResource("6_3atx1") stream = ExtResource("6_3atx1")
volume_db = 3.0 volume_db = 4.0
bus = &"SFX" bus = &"SFX"
[connection signal="animation_finished" from="GunAnims" to="." method="_on_gun_anims_animation_finished"] [connection signal="animation_finished" from="GunAnims" to="." method="_on_gun_anims_animation_finished"]

View File

@@ -278,7 +278,7 @@ _data = {
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.0145504, -0.0460228) transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.0145504, -0.0460228)
script = ExtResource("2_63tea") script = ExtResource("2_63tea")
gun_name = "Dumb Pistol" gun_name = "Dumb Pistol"
fire_mode = 1 fire_mode = 2
flare_light = NodePath("SpotLight3D") flare_light = NodePath("SpotLight3D")
bullet = ExtResource("3_4pvsf") bullet = ExtResource("3_4pvsf")
bullethole = ExtResource("4_bu1g0") bullethole = ExtResource("4_bu1g0")

View File

@@ -57,7 +57,7 @@ current = true
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.0341401, -0.111267) transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.0341401, -0.111267)
[node name="WeaponSpawner" type="Node3D" parent="Head/Camera3D/WeaponHolder"] [node name="WeaponSpawner" type="Node3D" parent="Head/Camera3D/WeaponHolder"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.44954, -0.202025, -1.03649) transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.45, -0.202, -0.951)
[node name="AmmoCounter" type="Label" parent="Head/Camera3D"] [node name="AmmoCounter" type="Label" parent="Head/Camera3D"]
offset_right = 3840.0 offset_right = 3840.0

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -55,6 +55,8 @@ collision_layer = 4
collision_mask = 6 collision_mask = 6
script = ExtResource("1_1udac") script = ExtResource("1_1udac")
collision_shape = NodePath("CollisionShape3D2") collision_shape = NodePath("CollisionShape3D2")
despawning = true
despawn_time_s = 20
pickupType = "stamina" pickupType = "stamina"
[node name="Area3D" type="Area3D" parent="."] [node name="Area3D" type="Area3D" parent="."]

View File

@@ -96,6 +96,11 @@ scroll_down={
"events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":0,"position":Vector2(0, 0),"global_position":Vector2(0, 0),"factor":1.0,"button_index":5,"canceled":false,"pressed":false,"double_click":false,"script":null) "events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":0,"position":Vector2(0, 0),"global_position":Vector2(0, 0),"factor":1.0,"button_index":5,"canceled":false,"pressed":false,"double_click":false,"script":null)
] ]
} }
escape={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194305,"key_label":0,"unicode":0,"echo":false,"script":null)
]
}
[rendering] [rendering]

View File

@@ -1,11 +1,11 @@
[gd_scene load_steps=52 format=3 uid="uid://dyop6vk3rgkkb"] [gd_scene load_steps=54 format=3 uid="uid://dyop6vk3rgkkb"]
[ext_resource type="Script" path="res://scripts/WeaponManager.gd" id="1_orhgl"] [ext_resource type="Script" path="res://scripts/WeaponManager.gd" id="1_orhgl"]
[ext_resource type="Texture2D" uid="uid://dqs06ic3vjtwk" path="res://assets/Models/asphalt1.albedo.jpg" id="1_w4rag"] [ext_resource type="Texture2D" uid="uid://dqs06ic3vjtwk" path="res://assets/Models/asphalt1.albedo.jpg" id="1_w4rag"]
[ext_resource type="PackedScene" uid="uid://brl0bsqjl5dg3" path="res://assets/mac_10.tscn" id="2_6rjit"] [ext_resource type="PackedScene" uid="uid://brl0bsqjl5dg3" path="res://assets/mac_10.tscn" id="2_6rjit"]
[ext_resource type="PackedScene" uid="uid://drwae3loscbw7" path="res://assets/player.tscn" id="2_f87c2"] [ext_resource type="PackedScene" uid="uid://drwae3loscbw7" path="res://assets/player.tscn" id="2_f87c2"]
[ext_resource type="PackedScene" uid="uid://b5eclfg0cmmal" path="res://assets/revolver_1.tscn" id="3_8ysrd"]
[ext_resource type="PackedScene" uid="uid://d1j6ktsmxfq6e" path="res://assets/spider.tscn" id="3_cvvjo"] [ext_resource type="PackedScene" uid="uid://d1j6ktsmxfq6e" path="res://assets/spider.tscn" id="3_cvvjo"]
[ext_resource type="PackedScene" uid="uid://dslxb3psx30vp" path="res://assets/pistol1.tscn" id="3_gjst3"]
[ext_resource type="PackedScene" uid="uid://20csd6dmwj4y" path="res://assets/jump_platform.tscn" id="4_8nxyr"] [ext_resource type="PackedScene" uid="uid://20csd6dmwj4y" path="res://assets/jump_platform.tscn" id="4_8nxyr"]
[ext_resource type="PackedScene" uid="uid://dws2vwfxubqvb" path="res://assets/cannon.tscn" id="5_28rul"] [ext_resource type="PackedScene" uid="uid://dws2vwfxubqvb" path="res://assets/cannon.tscn" id="5_28rul"]
[ext_resource type="PackedScene" uid="uid://bpkmyd3wvqi5p" path="res://assets/boombox.tscn" id="6_xrg7k"] [ext_resource type="PackedScene" uid="uid://bpkmyd3wvqi5p" path="res://assets/boombox.tscn" id="6_xrg7k"]
@@ -13,6 +13,8 @@
[ext_resource type="PackedScene" uid="uid://cnfc8rtk6l1d8" path="res://assets/crate1.tscn" id="8_b57j8"] [ext_resource type="PackedScene" uid="uid://cnfc8rtk6l1d8" path="res://assets/crate1.tscn" id="8_b57j8"]
[ext_resource type="PackedScene" uid="uid://djr7vnr1hcx82" path="res://assets/spiderTEst.tscn" id="12_gnu56"] [ext_resource type="PackedScene" uid="uid://djr7vnr1hcx82" path="res://assets/spiderTEst.tscn" id="12_gnu56"]
[ext_resource type="PackedScene" uid="uid://dws4iro7820fc" path="res://assets/pistol1_pickup.tscn" id="13_ne668"] [ext_resource type="PackedScene" uid="uid://dws4iro7820fc" path="res://assets/pistol1_pickup.tscn" id="13_ne668"]
[ext_resource type="PackedScene" uid="uid://dugcxo2665me0" path="res://assets/revolver1_pickup.tscn" id="14_m55rd"]
[ext_resource type="PackedScene" uid="uid://c7vrpfdh603kr" path="res://assets/bottle_1.tscn" id="15_3iv0j"]
[sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_nb6x7"] [sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_nb6x7"]
sky_top_color = Color(0.145935, 0.111347, 0.255579, 1) sky_top_color = Color(0.145935, 0.111347, 0.255579, 1)
@@ -416,7 +418,7 @@ size = Vector3(16.265, 5.07275, 15.3267)
script = ExtResource("1_orhgl") script = ExtResource("1_orhgl")
player = NodePath("Player") player = NodePath("Player")
gun_1 = ExtResource("2_6rjit") gun_1 = ExtResource("2_6rjit")
gun_2 = ExtResource("3_8ysrd") gun_2 = ExtResource("3_gjst3")
[node name="Player" parent="." instance=ExtResource("2_f87c2")] [node name="Player" parent="." instance=ExtResource("2_f87c2")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -4.0295, 1.4435, 21.1166) transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -4.0295, 1.4435, 21.1166)
@@ -645,4 +647,25 @@ mass = 10.0
transform = Transform3D(-1, 0, 8.74228e-08, 0, 1, 0, -8.74228e-08, 0, -1, -3.267, -0.228641, 15.75) transform = Transform3D(-1, 0, 8.74228e-08, 0, 1, 0, -8.74228e-08, 0, -1, -3.267, -0.228641, 15.75)
[node name="pistol1_pickup" parent="." instance=ExtResource("13_ne668")] [node name="pistol1_pickup" parent="." instance=ExtResource("13_ne668")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -4.53831, 43.775, 20.8225) transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -3.7227, 43.775, -30.187)
[node name="pistol1_pickup2" parent="." instance=ExtResource("14_m55rd")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -3, 44, 28)
[node name="bottle1" parent="." instance=ExtResource("15_3iv0j")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -4.88146, 0.608878, 12.1473)
[node name="bottle2" parent="." instance=ExtResource("15_3iv0j")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -4.36049, 0.608878, 12.1525)
[node name="bottle3" parent="." instance=ExtResource("15_3iv0j")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -4.64453, 0.608878, 11.7534)
[node name="bottle4" parent="." instance=ExtResource("15_3iv0j")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -4.60098, 1.79509, 12.0165)
[node name="bottle5" parent="." instance=ExtResource("15_3iv0j")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -3.60763, 1.16757, 11.4412)
[node name="bottle6" parent="." instance=ExtResource("15_3iv0j")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -2.69462, 1.16757, 11.2398)

13
scripts/breakable.gd Normal file
View File

@@ -0,0 +1,13 @@
extends RigidBody3D
@export var broken_object : Resource
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
pass

View File

@@ -0,0 +1,16 @@
extends Node3D
@export var sound : Node
@export var pitch_scale_amt = .5
var rng = RandomNumberGenerator.new()
# Called when the node enters the scene tree for the first time.
func _ready():
if sound != null:
sound.pitch_scale = 1 + rng.randf_range(-pitch_scale_amt,pitch_scale_amt)
sound.play()
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
pass

View File

@@ -58,6 +58,13 @@ func _process(delta):
if ray.get_collider().is_in_group("scene_rigidbody"): if ray.get_collider().is_in_group("scene_rigidbody"):
ray.get_collider().linear_velocity += transform.basis * Vector3(0,0,-1 * 5) ray.get_collider().linear_velocity += transform.basis * Vector3(0,0,-1 * 5)
if ray.get_collider().is_in_group("breakable"):
var spawn_broken = ray.get_collider().broken_object.instantiate()
spawn_broken.position = ray.get_collider().global_position
spawn_broken.transform.basis = ray.get_collider().global_transform.basis
get_tree().get_root().add_child(spawn_broken)
ray.get_collider().queue_free()
if ray.get_collider().is_in_group("enemy"): if ray.get_collider().is_in_group("enemy"):
print("enemy hit") print("enemy hit")
hit_indicator.play() hit_indicator.play()

View File

@@ -188,6 +188,10 @@ func _physics_process(delta):
gun.anim_player.play("swap_out") gun.anim_player.play("swap_out")
level_control.gun_spawn(level_control.current_gun_index - 1) level_control.gun_spawn(level_control.current_gun_index - 1)
#quit game and eventually go to menu
if Input.is_action_pressed("escape"):
get_tree().quit()
move_and_slide() move_and_slide()
weapon_tilt(input_dir.x, delta) weapon_tilt(input_dir.x, delta)
weapon_sway(delta) weapon_sway(delta)