diff --git a/assets/Audio/Weapons/bullet-fly-by-impact-metal-SBA-300114994.wav b/assets/Audio/Weapons/bullet-fly-by-impact-metal-SBA-300114994.wav new file mode 100644 index 0000000..2aae4be Binary files /dev/null and b/assets/Audio/Weapons/bullet-fly-by-impact-metal-SBA-300114994.wav differ diff --git a/assets/Audio/Weapons/bullet-fly-by-impact-metal-SBA-300114994.wav.import b/assets/Audio/Weapons/bullet-fly-by-impact-metal-SBA-300114994.wav.import new file mode 100644 index 0000000..3c6abf4 --- /dev/null +++ b/assets/Audio/Weapons/bullet-fly-by-impact-metal-SBA-300114994.wav.import @@ -0,0 +1,24 @@ +[remap] + +importer="wav" +type="AudioStreamWAV" +uid="uid://bftxcv3m2y8qm" +path="res://.godot/imported/bullet-fly-by-impact-metal-SBA-300114994.wav-f04baa74189de33586537017ea4b819f.sample" + +[deps] + +source_file="res://assets/Audio/Weapons/bullet-fly-by-impact-metal-SBA-300114994.wav" +dest_files=["res://.godot/imported/bullet-fly-by-impact-metal-SBA-300114994.wav-f04baa74189de33586537017ea4b819f.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 diff --git a/assets/Audio/Weapons/pistol-44-magnum-single-shot-exterior-SBA-300083879.wav b/assets/Audio/Weapons/pistol-44-magnum-single-shot-exterior-SBA-300083879.wav new file mode 100644 index 0000000..c90e750 Binary files /dev/null and b/assets/Audio/Weapons/pistol-44-magnum-single-shot-exterior-SBA-300083879.wav differ diff --git a/assets/Audio/Weapons/pistol-44-magnum-single-shot-exterior-SBA-300083879.wav.import b/assets/Audio/Weapons/pistol-44-magnum-single-shot-exterior-SBA-300083879.wav.import new file mode 100644 index 0000000..c153ee8 --- /dev/null +++ b/assets/Audio/Weapons/pistol-44-magnum-single-shot-exterior-SBA-300083879.wav.import @@ -0,0 +1,24 @@ +[remap] + +importer="wav" +type="AudioStreamWAV" +uid="uid://jyuolavuxs1h" +path="res://.godot/imported/pistol-44-magnum-single-shot-exterior-SBA-300083879.wav-bccd2d67cb8e09554be158da03b465d4.sample" + +[deps] + +source_file="res://assets/Audio/Weapons/pistol-44-magnum-single-shot-exterior-SBA-300083879.wav" +dest_files=["res://.godot/imported/pistol-44-magnum-single-shot-exterior-SBA-300083879.wav-bccd2d67cb8e09554be158da03b465d4.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 diff --git a/assets/Models/Trees1_v2.blend b/assets/Models/Trees1_v2.blend index d701a3f..1eeb088 100644 Binary files a/assets/Models/Trees1_v2.blend and b/assets/Models/Trees1_v2.blend differ diff --git a/assets/Models/Trees1_v2.blend1 b/assets/Models/Trees1_v2.blend1 index 035b1d5..d701a3f 100644 Binary files a/assets/Models/Trees1_v2.blend1 and b/assets/Models/Trees1_v2.blend1 differ diff --git a/assets/blockout_2.tscn b/assets/blockout_2.tscn index 9f15251..0bbd3fb 100644 --- a/assets/blockout_2.tscn +++ b/assets/blockout_2.tscn @@ -897,6 +897,7 @@ _data = { [node name="BLOCKOUT2Test" type="Node3D" node_paths=PackedStringArray("player")] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.016016, 0.0225029, -0.0192337) script = ExtResource("1_sbpvn") +load_save = false player = NodePath("Player") money = 50 start_health = 5 diff --git a/assets/bottle_1_pieces.tscn b/assets/bottle_1_pieces.tscn index d0c42fc..6e4ce32 100644 --- a/assets/bottle_1_pieces.tscn +++ b/assets/bottle_1_pieces.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=19 format=4 uid="uid://bdy5isxqwbjq8"] +[gd_scene load_steps=20 format=4 uid="uid://bdy5isxqwbjq8"] [ext_resource type="Script" path="res://scripts/broken_object_spawn.gd" id="1_3nyc3"] [ext_resource type="AudioStream" uid="uid://bn4y63ws8jscs" path="res://assets/Audio/glass-break-two-thick-glasses-SBA-300121605.wav" id="1_vmlqu"] @@ -46,6 +46,11 @@ shadow_mesh = SubResource("ArrayMesh_tfdks") [sub_resource type="ConvexPolygonShape3D" id="ConvexPolygonShape3D_0sbf2"] points = PackedVector3Array(0.0974093, 0.152932, -0.0713481, -0.132998, -0.283936, 0.0526213, -0.102607, -0.282655, -0.0206982, 0.259721, -0.217894, 0.0291036, -0.0957838, 0.0756587, 0.191345, 0.0433577, -0.248832, 0.260882, 0.073675, -0.263854, -0.133599, -0.0807777, 0.0768671, -0.0722225, 0.221051, -0.00931318, -0.0636392, 0.0808388, 0.0771109, -0.131298, -0.0416929, 0.176124, 0.0831446, -0.0803236, -0.279771, 0.191345, -0.132561, 0.0770819, 0.0526381, -0.057153, -0.295216, -0.0713875, 0.206117, -0.22472, -0.0799446, 0.035608, -0.210244, 0.260882, 0.0124374, 0.199316, -0.0095589, 0.16696, 0.0834055, -0.102262, -0.0737514, -0.283533, -0.0798702, 0.0514377, 0.0771098, -0.131296, 0.251972, -0.187004, 0.0291036, -0.0811622, -0.261582, 0.207278, -0.133033, -0.28398, 0.0820919, 0.205591, -0.241134, -0.0636392, -0.0648634, -0.00166329, 0.22222, -0.0882645, 0.14316, 0.0599786, -0.132638, 0.0771321, 0.0820464, -0.0441972, 0.143265, -0.042977, 0.00472699, 0.199316, 0.0136465, 0.0124374, -0.19475, 0.260882, 0.0514207, -0.26178, -0.13174, 0.0587786, 0.143141, -0.0870212) +[sub_resource type="AudioStreamRandomizer" id="AudioStreamRandomizer_f7avk"] +random_pitch = 2.0 +streams_count = 1 +stream_0/stream = ExtResource("1_vmlqu") + [sub_resource type="ArrayMesh" id="ArrayMesh_g1uxi"] _surfaces = [{ "aabb": AABB(-0.184698, -0.0943551, -0.0695819, 0.376365, 0.480613, 0.166746), @@ -213,7 +218,7 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.066139, 0.324223, -0.06741 shape = SubResource("ConvexPolygonShape3D_0sbf2") [node name="BrokenSound" type="AudioStreamPlayer3D" parent="Piece 1"] -stream = ExtResource("1_vmlqu") +stream = SubResource("AudioStreamRandomizer_f7avk") [node name="Piece 2" type="RigidBody3D" parent="." groups=["scene_rigidbody"]] collision_layer = 32 diff --git a/assets/bullet_hole.tscn b/assets/bullet_hole.tscn index 0e76c72..f72d914 100644 --- a/assets/bullet_hole.tscn +++ b/assets/bullet_hole.tscn @@ -1,8 +1,9 @@ -[gd_scene load_steps=6 format=3 uid="uid://crvohhc6kgshn"] +[gd_scene load_steps=8 format=3 uid="uid://crvohhc6kgshn"] [ext_resource type="Script" path="res://scripts/bullet_hole.gd" id="1_r63bq"] [ext_resource type="Texture2D" uid="uid://clj3jr8fnrut4" path="res://assets/Textures/bulletholeMASK.png" id="2_4q4gp"] [ext_resource type="Texture2D" uid="uid://c03mwq2gxs7u0" path="res://assets/Textures/bullethole.normal.png" id="2_s81sk"] +[ext_resource type="AudioStream" uid="uid://bftxcv3m2y8qm" path="res://assets/Audio/Weapons/bullet-fly-by-impact-metal-SBA-300114994.wav" id="4_p3syg"] [sub_resource type="PlaneMesh" id="PlaneMesh_rv5u3"] size = Vector2(0.1, 0.1) @@ -15,18 +16,28 @@ blend_mode = 3 albedo_texture = ExtResource("2_4q4gp") metallic_specular = 0.0 normal_enabled = true -normal_scale = 10.0 +normal_scale = 16.0 normal_texture = ExtResource("2_s81sk") +[sub_resource type="AudioStreamRandomizer" id="AudioStreamRandomizer_tvxaj"] +random_pitch = 1.1 +random_volume_offset_db = 1.0 +streams_count = 1 +stream_0/stream = ExtResource("4_p3syg") + [node name="BulletHole" type="Node3D" groups=["spawned"]] script = ExtResource("1_r63bq") [node name="MeshInstance3D" type="MeshInstance3D" parent="."] -transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, 0, 0, 0) +transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, 0, 0, -0.00441801) mesh = SubResource("PlaneMesh_rv5u3") surface_material_override/0 = SubResource("StandardMaterial3D_y0mpl") [node name="Timer" type="Timer" parent="."] wait_time = 60.0 +[node name="AudioStreamPlayer3D" type="AudioStreamPlayer3D" parent="."] +stream = SubResource("AudioStreamRandomizer_tvxaj") +autoplay = true + [connection signal="timeout" from="Timer" to="." method="_on_timer_timeout"] diff --git a/assets/casing_2.tscn b/assets/casing.tscn similarity index 70% rename from assets/casing_2.tscn rename to assets/casing.tscn index 8dfb6b9..323b7c1 100644 --- a/assets/casing_2.tscn +++ b/assets/casing.tscn @@ -1,11 +1,11 @@ [gd_scene load_steps=9 format=3 uid="uid://c1gdehrsytlkk"] -[ext_resource type="PackedScene" uid="uid://bv0sfqdgwa85p" path="res://assets/Models/casing.blend" id="1_8ox1t"] -[ext_resource type="Script" path="res://assets/casing.gd" id="1_34yke"] -[ext_resource type="AudioStream" uid="uid://csxr3p04o7tsm" path="res://assets/Audio/bullet-metal-casing-drop-1.mp3" id="3_afujv"] -[ext_resource type="AudioStream" uid="uid://dye211r1fct2k" path="res://assets/Audio/bullet-metal-casing-drop-2.mp3" id="4_q87pa"] -[ext_resource type="AudioStream" uid="uid://bvfsycfblxn4j" path="res://assets/Audio/bullet-metal-casing-drop-3.mp3" id="5_3aif6"] -[ext_resource type="AudioStream" uid="uid://b4fyx4keuu0x4" path="res://assets/Audio/bullet-metal-casing-drop-4.mp3" id="6_447b3"] +[ext_resource type="Script" path="res://assets/casing.gd" id="1_6f8y7"] +[ext_resource type="PackedScene" uid="uid://bv0sfqdgwa85p" path="res://assets/Models/casing.blend" id="2_1ed71"] +[ext_resource type="AudioStream" uid="uid://csxr3p04o7tsm" path="res://assets/Audio/bullet-metal-casing-drop-1.mp3" id="3_6sr5n"] +[ext_resource type="AudioStream" uid="uid://dye211r1fct2k" path="res://assets/Audio/bullet-metal-casing-drop-2.mp3" id="4_bobmv"] +[ext_resource type="AudioStream" uid="uid://bvfsycfblxn4j" path="res://assets/Audio/bullet-metal-casing-drop-3.mp3" id="5_wvj0r"] +[ext_resource type="AudioStream" uid="uid://b4fyx4keuu0x4" path="res://assets/Audio/bullet-metal-casing-drop-4.mp3" id="6_qbbeb"] [sub_resource type="CylinderShape3D" id="CylinderShape3D_ejwa0"] margin = 0.001 @@ -14,23 +14,23 @@ radius = 0.0314789 [sub_resource type="AudioStreamRandomizer" id="AudioStreamRandomizer_kdfna"] streams_count = 4 -stream_0/stream = ExtResource("3_afujv") -stream_1/stream = ExtResource("4_q87pa") -stream_2/stream = ExtResource("5_3aif6") -stream_3/stream = ExtResource("6_447b3") +stream_0/stream = ExtResource("3_6sr5n") +stream_1/stream = ExtResource("4_bobmv") +stream_2/stream = ExtResource("5_wvj0r") +stream_3/stream = ExtResource("6_qbbeb") -[node name="casing_2" type="RigidBody3D" groups=["scene_rigidbody", "spawned"]] +[node name="casing" type="RigidBody3D" groups=["scene_rigidbody", "spawned"]] collision_layer = 0 -collision_mask = 37 +collision_mask = 165 mass = 0.1 continuous_cd = true contact_monitor = true max_contacts_reported = 1 linear_damp = 0.1 angular_damp = 0.1 -script = ExtResource("1_34yke") +script = ExtResource("1_6f8y7") -[node name="casing2" parent="." instance=ExtResource("1_8ox1t")] +[node name="casing2" parent="." instance=ExtResource("2_1ed71")] transform = Transform3D(0.00523598, 9.20392e-06, -1.49999, 1.49999, 0.00261793, 0.00523599, 0.00261795, -1.5, -6.55667e-08, 0, 0, 0) [node name="CollisionShape3D" type="CollisionShape3D" parent="."] diff --git a/assets/mac_10.tscn b/assets/mac_10.tscn index 79208d1..b2eb4d2 100644 --- a/assets/mac_10.tscn +++ b/assets/mac_10.tscn @@ -6,7 +6,7 @@ [ext_resource type="PackedScene" uid="uid://dqhltdnqyg8ni" path="res://assets/bullet.tscn" id="3_w1kko"] [ext_resource type="PackedScene" uid="uid://crvohhc6kgshn" path="res://assets/bullet_hole.tscn" id="4_eleuq"] [ext_resource type="PackedScene" uid="uid://cp8563f0oxvff" path="res://assets/mag1.tscn" id="4_ji2hu"] -[ext_resource type="PackedScene" uid="uid://c1gdehrsytlkk" path="res://assets/casing_2.tscn" id="4_kpr3h"] +[ext_resource type="PackedScene" uid="uid://c1gdehrsytlkk" path="res://assets/casing.tscn" id="4_kpr3h"] [ext_resource type="AudioStream" uid="uid://t50i483xmj3a" path="res://assets/Audio/Weapons/toy-click-spin-SBA-300071143.wav" id="5_rn7j1"] [ext_resource type="AudioStream" uid="uid://db3iy0f1pa5lg" path="res://assets/Audio/Weapons/gun-m-16-reload-full-clip-magazine-SBA-300121257.wav" id="6_3atx1"] [ext_resource type="Texture2D" uid="uid://dtg3nb2ew72c3" path="res://assets/star_05.png" id="7_h63ea"] diff --git a/assets/pistol1.tscn b/assets/pistol1.tscn index 9619203..1101088 100644 --- a/assets/pistol1.tscn +++ b/assets/pistol1.tscn @@ -3,7 +3,7 @@ [ext_resource type="PackedScene" uid="uid://svrb3n31mkag" path="res://assets/Models/gun.blend" id="1_frekg"] [ext_resource type="Script" path="res://scripts/trackerGun.gd" id="2_ieev5"] [ext_resource type="PackedScene" uid="uid://crvohhc6kgshn" path="res://assets/bullet_hole.tscn" id="4_bu1g0"] -[ext_resource type="PackedScene" uid="uid://c1gdehrsytlkk" path="res://assets/casing_2.tscn" id="5_gls8p"] +[ext_resource type="PackedScene" uid="uid://c1gdehrsytlkk" path="res://assets/casing.tscn" id="5_gls8p"] [ext_resource type="PackedScene" uid="uid://cp8563f0oxvff" path="res://assets/mag1.tscn" id="6_ysonb"] [ext_resource type="AudioStream" uid="uid://bxjv50ivk3fvn" path="res://assets/Audio/Weapons/9mm Full Size Pistol/Gunshots/9mm Full Size Pistol - Gunshot B 001.wav" id="7_25stk"] [ext_resource type="AudioStream" uid="uid://t50i483xmj3a" path="res://assets/Audio/Weapons/toy-click-spin-SBA-300071143.wav" id="9_btm61"] diff --git a/assets/player.tscn b/assets/player.tscn index df8dad9..970b2dc 100644 --- a/assets/player.tscn +++ b/assets/player.tscn @@ -203,8 +203,11 @@ material = SubResource("ShaderMaterial_ubnx7") offset_right = 3840.0 offset_bottom = 2160.0 -[node name="MoveableHolder" type="Node3D" parent="Head"] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.287198, -2.1034) +[node name="MoveableHolder" type="Node3D" parent="Head/Recoil/Camera3D"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.000759602, -1.79822) + +[node name="MoveableRotation" type="Node3D" parent="Head/Recoil/Camera3D/MoveableHolder"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1.73907) [node name="StandCheck" type="RayCast3D" parent="."] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.989648, 0) diff --git a/assets/revolver_1.tscn b/assets/revolver_1.tscn index 5db53e0..d914af2 100644 --- a/assets/revolver_1.tscn +++ b/assets/revolver_1.tscn @@ -5,7 +5,7 @@ [ext_resource type="PackedScene" uid="uid://dqhltdnqyg8ni" path="res://assets/bullet.tscn" id="3_32prk"] [ext_resource type="Texture2D" uid="uid://dtg3nb2ew72c3" path="res://assets/star_05.png" id="3_q41fl"] [ext_resource type="PackedScene" uid="uid://crvohhc6kgshn" path="res://assets/bullet_hole.tscn" id="4_ubqgq"] -[ext_resource type="PackedScene" uid="uid://c1gdehrsytlkk" path="res://assets/casing_2.tscn" id="5_m3vsl"] +[ext_resource type="PackedScene" uid="uid://c1gdehrsytlkk" path="res://assets/casing.tscn" id="5_m3vsl"] [ext_resource type="Texture2D" uid="uid://dit5pj07jr02y" path="res://assets/Models/revolver1.albedo.png" id="6_acf6f"] [ext_resource type="AudioStream" uid="uid://dywuxr61pit5t" path="res://assets/Audio/Weapons/38 SPL Revolver/Gunshots/38 SPL Revolver - Gunshot B 001.wav" id="7_ve411"] [ext_resource type="Texture2D" uid="uid://b36a5av7x827o" path="res://assets/Models/revolver1.roughness.png" id="7_w8q3k"] diff --git a/demo/components/Player.tscn b/demo/components/Player.tscn deleted file mode 100644 index b8e81c7..0000000 --- a/demo/components/Player.tscn +++ /dev/null @@ -1,44 +0,0 @@ -[gd_scene load_steps=7 format=3 uid="uid://domhm87hbhbg1"] - -[ext_resource type="Script" path="res://demo/src/Player.gd" id="1_nm1yx"] -[ext_resource type="Script" path="res://demo/src/CameraManager.gd" id="2_loos7"] - -[sub_resource type="SphereShape3D" id="SphereShape3D_smq6u"] - -[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_lwhhq"] -height = 1.5 - -[sub_resource type="SeparationRayShape3D" id="SeparationRayShape3D_twc2s"] - -[sub_resource type="CapsuleMesh" id="CapsuleMesh_lsqiy"] - -[node name="Player" type="CharacterBody3D"] -collision_layer = 2 -script = ExtResource("1_nm1yx") - -[node name="CameraManager" type="Node3D" parent="."] -script = ExtResource("2_loos7") - -[node name="Arm" type="SpringArm3D" parent="CameraManager"] -unique_name_in_owner = true -transform = Transform3D(1, 0, 0, 0, 0.906308, 0.422618, 0, -0.422618, 0.906308, 0, 2.32515, -0.0321627) -shape = SubResource("SphereShape3D_smq6u") -spring_length = 6.0 -margin = 0.5 - -[node name="Camera3D" type="Camera3D" parent="CameraManager/Arm"] -unique_name_in_owner = true -near = 0.25 -far = 16384.0 - -[node name="CollisionShapeBody" type="CollisionShape3D" parent="."] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.25, 0) -shape = SubResource("CapsuleShape3D_lwhhq") - -[node name="CollisionShapeRay" type="CollisionShape3D" parent="."] -transform = Transform3D(1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, 1, 0) -shape = SubResource("SeparationRayShape3D_twc2s") - -[node name="Body" type="MeshInstance3D" parent="."] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0) -mesh = SubResource("CapsuleMesh_lsqiy") diff --git a/scripts/bullet.gd b/scripts/bullet.gd index a09fa68..a893580 100644 --- a/scripts/bullet.gd +++ b/scripts/bullet.gd @@ -31,7 +31,7 @@ func _physics_process(delta): distance_from_player = abs(self.global_position - player_position) - if distance_from_player.length() > 1.5: + if distance_from_player.length() > 2: visible = true if ray.is_colliding(): diff --git a/scripts/player.gd b/scripts/player.gd index eb8ff5d..29f7527 100644 --- a/scripts/player.gd +++ b/scripts/player.gd @@ -6,6 +6,7 @@ const FLASHLIGHT_BRIGHTNESS = 30 const KICK_AMOUNT = 20 const LAND_CAMERA_TILT : Vector3 = Vector3(-1,0,0) const WALK_SPEED = 12.0 +const CROUCH_SPEED = 6.0 const SPRINT_SPEED = 15.0 const DASH_SPEED = 40 const SLOWSPEED = .1 @@ -74,8 +75,12 @@ var held_item_linear_damp_cache var held_item_angular_damp_cache var held_item_gravity_cache var held_item_mass_cache +var held_item_collision_cache var held_item_rotation = Vector3(0,0,0) var gamespeed_controlled = false +var crouched_pos = Vector3(0,0,0) +var stand_pos = Vector3(0,0.889,0) +var crouched = false # Slow Down Variables var remaining_stamina : float = MAX_STAMINA @@ -108,7 +113,8 @@ var controlled_elsewhere = false @onready var kick_audio: AudioStreamPlayer3D = $Head/Recoil/Camera3D/Audio/Kick @onready var weapon_pickup_audio: AudioStreamPlayer = $Audio/WeaponPickup @onready var crt_filter: ColorRect = $Head/Recoil/Camera3D/crtFilter -@onready var moveable_holder: Node3D = $Head/MoveableHolder +@onready var moveable_holder: Node3D = $Head/Recoil/Camera3D/MoveableHolder +@onready var moveable_rotation: Node3D = $Head/Recoil/Camera3D/MoveableHolder/MoveableRotation @onready var stand_check: RayCast3D = $StandCheck @onready var r_hand_test: MeshInstance3D = $Head/Recoil/Camera3D/WeaponHolder/RHandTest @onready var enemy_killed_audio: AudioStreamPlayer = $Audio/EnemyKilled @@ -131,6 +137,8 @@ func _ready(): health_indicator.size = Vector2(viewportWidth,viewportHeight) health_indicator.color = Color(0.471, 0, 0, 0) + speed = WALK_SPEED + crt_filter.visible = false #turn off audio if unchecked in player @@ -173,10 +181,10 @@ func _physics_process(delta): velocity.y += JUMP_VELOCITY double_jump = false - speed = WALK_SPEED #the fuck is this line doing if Input.is_action_just_pressed("crouch"): - velocity.y -= JUMP_VELOCITY * 4 + crouched = !crouched + # Get the input direction and handle the movement/deceleration. var input_dir = Input.get_vector("move_left", "move_right", "move_up", "move_down") @@ -308,7 +316,7 @@ func _physics_process(delta): gun.anim_player.play("swap_out") level_control.gun_spawn(level_control.current_gun_index + 1) else: - held_item_rotation.y = clamp(held_item_rotation.y + deg_to_rad(45), deg_to_rad(0),deg_to_rad(360)) + moveable_holder.rotation.y += deg_to_rad(45) #Weapon Swap Down if Input.is_action_just_pressed("scroll_down") and !gun.anim_player.is_playing(): @@ -317,7 +325,7 @@ func _physics_process(delta): gun.anim_player.play("swap_out") level_control.gun_spawn(level_control.current_gun_index - 1) else: - held_item_rotation.y = clamp(held_item_rotation.y - deg_to_rad(45), deg_to_rad(0),deg_to_rad(360)) + moveable_holder.rotation.y -= deg_to_rad(45) for i in range(10): if Input.is_action_just_pressed("numb_" + str(i)): @@ -354,12 +362,22 @@ func _physics_process(delta): if level_control.health <= 0: level_control.die() - hold_item() + hold_item(delta) move_and_slide() + crouch(delta) weapon_tilt(input_dir.x, delta) weapon_sway(delta) weapon_bob(velocity.length(), delta) +func crouch(delta): + if crouched: + if head.position != crouched_pos: + head.position = lerp(head.position, crouched_pos, delta * 8) + speed = CROUCH_SPEED + else: + if head.position != stand_pos: + head.position = lerp(head.position, stand_pos, delta * 8) + speed = WALK_SPEED func _headbob(time) -> Vector3: var pos = Vector3.ZERO @@ -379,7 +397,7 @@ func _on_pick_up_detection_body_entered(body): weapon_pickup_audio.play() -func ladder_collide(is_climbing): +func ladder_collide(): if is_climbing == true: gravity = 0.0 else: @@ -442,28 +460,28 @@ func toggle_hud(hud_on): stamina_counter.visible = hud_on func grab_moveable(body): - moveable_holder.global_position = body.global_position held_item = body - held_item_rotation = Vector3(0,0,0)#body.rotation #cache rigidbody settings held_item_linear_damp_cache = body.linear_damp held_item_angular_damp_cache = body.angular_damp held_item_gravity_cache = body.gravity_scale held_item_mass_cache = body.mass + held_item_collision_cache = held_item.get_collision_layer_value(1) #change rigidbody settings body.linear_damp = 0 #5 body.angular_damp = 0 #5 body.mass = 1 held_item.gravity_scale = 0 + held_item.set_collision_layer_value(1,false) -func hold_item(): +func hold_item(_delta): # Move Held Items if held_item != null: - var held_dir = moveable_holder.global_position - held_item.global_position - var held_av = held_item_rotation - held_item.rotation + interact_ray.look_at(held_item.global_position, Vector3.UP) + var hold_offset = held_item.global_position - interact_ray.get_collision_point() + var held_dir = (moveable_holder.global_position - held_item.global_position) + hold_offset held_item.linear_velocity = held_dir * 15 - held_item.look_at(camera.global_position) - #held_item.angular_velocity = held_av * 10 + held_item.look_at(moveable_rotation.global_position, Vector3.UP) #break when moved too far away var distance_from_player = abs(self.global_position - held_item.global_position) @@ -474,12 +492,14 @@ func hold_item(): release_moveable() func release_moveable(): - held_item_rotation = Vector3(0,0,0) - held_item.gravity_scale = held_item_gravity_cache - held_item.linear_damp = held_item_linear_damp_cache - held_item.angular_damp = held_item_angular_damp_cache - held_item.mass = held_item_mass_cache - held_item = null + if held_item != null: + held_item.gravity_scale = held_item_gravity_cache + held_item.linear_damp = held_item_linear_damp_cache + held_item.angular_damp = held_item_angular_damp_cache + held_item.mass = held_item_mass_cache + held_item.set_collision_layer_value(1,held_item_collision_cache) + held_item = null + moveable_holder.rotation = Vector3(0,0,0) func hit(damage, fired_by, target_type): level_control.health -= damage