Make it possible to dynamically set weapon parans

This commit is contained in:
Nikolai Rodionov 2025-01-28 10:51:45 +01:00
parent 06a1d28e42
commit b54ffaeb0d
Signed by: allanger
GPG Key ID: 09F8B434D0FDD99B
11 changed files with 106 additions and 83 deletions

View File

@ -1419,12 +1419,12 @@ shape = SubResource("SphereShape3D_axep3")
[node name="PhysicalBoneSimulator3D" type="PhysicalBoneSimulator3D" parent="Body/Armature/Skeleton3D"] [node name="PhysicalBoneSimulator3D" type="PhysicalBoneSimulator3D" parent="Body/Armature/Skeleton3D"]
[node name="Physical Bone mixamorig_Hips" type="PhysicalBone3D" parent="Body/Armature/Skeleton3D/PhysicalBoneSimulator3D"] [node name="Physical Bone mixamorig_Hips" type="PhysicalBone3D" parent="Body/Armature/Skeleton3D/PhysicalBoneSimulator3D"]
transform = Transform3D(82.5044, -54.0559, -16.4615, 55.0482, 83.4649, 1.8195, 12.756, -10.5629, 98.619, 1.31498, 0.290623, -87.4646) transform = Transform3D(82.5044, -54.0559, -16.4615, 55.0482, 83.4649, 1.8195, 12.756, -10.5629, 98.619, 1.31498, 0.290624, -87.4646)
collision_layer = 4 collision_layer = 4
collision_mask = 4 collision_mask = 4
joint_type = 1 joint_type = 1
joint_offset = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -6.50607e-08, -5.58794e-09, 0.0499956) joint_offset = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -8.35348e-08, -8.84756e-09, 0.0499956)
body_offset = Transform3D(100, -0.0695305, -0.00860631, -1.00136e-05, 12.2744, -99.2438, 0.0700493, 99.2438, 12.2744, 0.000436783, 4.96175, -0.613665) body_offset = Transform3D(100, -0.0695305, -0.00860751, -1.19209e-05, 12.2744, -99.2438, 0.0700493, 99.2438, 12.2744, 0.00043869, 4.96175, -0.613665)
mass = 20.0 mass = 20.0
bone_name = "mixamorig_Hips" bone_name = "mixamorig_Hips"
joint_constraints/bias = 0.3 joint_constraints/bias = 0.3
@ -1436,12 +1436,12 @@ transform = Transform3D(0.01, 0, 0, 0, -4.37114e-10, 0.01, 0, -0.01, -4.37114e-1
shape = SubResource("CapsuleShape3D_0ptuo") shape = SubResource("CapsuleShape3D_0ptuo")
[node name="Physical Bone mixamorig_Spine" type="PhysicalBone3D" parent="Body/Armature/Skeleton3D/PhysicalBoneSimulator3D"] [node name="Physical Bone mixamorig_Spine" type="PhysicalBone3D" parent="Body/Armature/Skeleton3D/PhysicalBoneSimulator3D"]
transform = Transform3D(80.9412, -58.5461, -4.56913, 57.6046, 80.6695, -13.1964, 11.4119, 8.0493, 99.0201, 2.40599, 0.973749, -98.2036) transform = Transform3D(80.9412, -58.546, -4.56913, 57.6046, 80.6695, -13.1964, 11.4119, 8.0493, 99.0201, 2.40599, 0.973749, -98.2036)
collision_layer = 4 collision_layer = 4
collision_mask = 4 collision_mask = 4
joint_type = 1 joint_type = 1
joint_offset = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 5.06134e-09, 2.2377e-09, 0.05866) joint_offset = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 4.2222e-09, 2.2377e-09, 0.0586601)
body_offset = Transform3D(100, 1.52588e-05, 7.62939e-06, 4.76837e-06, -9.53674e-07, -100, -1.52588e-05, 100, -3.8147e-06, -9.53674e-07, 5.866, 0) body_offset = Transform3D(100, 7.62939e-06, 9.05991e-06, 4.76837e-06, -1.90735e-06, -100, -1.52588e-05, 100, -3.8147e-06, -9.53674e-07, 5.866, 0)
mass = 20.0 mass = 20.0
bone_name = "mixamorig_Spine" bone_name = "mixamorig_Spine"
joint_constraints/bias = 0.3 joint_constraints/bias = 0.3
@ -1453,12 +1453,12 @@ transform = Transform3D(0.0318071, 3.86358e-14, 4.9738e-14, -2.13163e-14, -1.629
shape = SubResource("CapsuleShape3D_126jt") shape = SubResource("CapsuleShape3D_126jt")
[node name="Physical Bone mixamorig_Head" type="PhysicalBone3D" parent="Body/Armature/Skeleton3D/PhysicalBoneSimulator3D"] [node name="Physical Bone mixamorig_Head" type="PhysicalBone3D" parent="Body/Armature/Skeleton3D/PhysicalBoneSimulator3D"]
transform = Transform3D(-97.8019, 4.47329, 20.366, -15.8369, -79.4709, -58.5966, 13.5638, -60.5339, 78.4325, -13.8193, 23.4986, -143.635) transform = Transform3D(-97.8019, 4.4733, 20.366, -15.8369, -79.4709, -58.5966, 13.5638, -60.5339, 78.4325, -13.8193, 23.4986, -143.635)
collision_layer = 4 collision_layer = 4
collision_mask = 4 collision_mask = 4
joint_type = 1 joint_type = 1
joint_offset = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -8.83517e-10, -1.39698e-07, 0.0981531) joint_offset = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -3.90303e-08, -1.37836e-07, 0.0981531)
body_offset = Transform3D(-100, -0.00220108, -0.000778198, -5.24521e-06, 33.8066, -94.1122, 0.00232792, -94.1122, -33.8066, 7.62939e-05, 9.23741, 3.31821) body_offset = Transform3D(-100, -0.00220013, -0.000778198, -5.24521e-06, 33.8066, -94.1122, 0.00232792, -94.1122, -33.8066, 7.24792e-05, 9.23741, 3.31821)
mass = 7.0 mass = 7.0
bone_name = "mixamorig_Head" bone_name = "mixamorig_Head"
joint_constraints/bias = 0.3 joint_constraints/bias = 0.3
@ -1474,8 +1474,8 @@ transform = Transform3D(86.1165, 14.0252, -48.8594, -45.4995, 64.1262, -61.787,
collision_layer = 4 collision_layer = 4
collision_mask = 4 collision_mask = 4
joint_type = 1 joint_type = 1
joint_offset = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 4.70432e-08, 8.67479e-08, 0.137023) joint_offset = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 3.65892e-08, 2.39336e-07, 0.137023)
body_offset = Transform3D(100, -3.05176e-05, -3.43323e-05, 1.71661e-05, 100, -7.62939e-06, 1.52588e-05, -3.8147e-06, 100, 0, -7.62939e-06, -13.7023) body_offset = Transform3D(100, -3.05176e-05, -2.67029e-05, 2.09808e-05, 100, -7.62939e-06, 1.71661e-05, -3.8147e-06, 100, 0, -2.28882e-05, -13.7023)
mass = 3.0 mass = 3.0
bone_name = "mixamorig_LeftArm" bone_name = "mixamorig_LeftArm"
joint_constraints/bias = 0.3 joint_constraints/bias = 0.3
@ -1491,8 +1491,8 @@ transform = Transform3D(-48.2566, -12.058, 86.752, -78.7312, -37.4258, -48.997,
collision_layer = 4 collision_layer = 4
collision_mask = 4 collision_mask = 4
joint_type = 1 joint_type = 1
joint_offset = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -2.52506e-07, 1.36787e-07, 0.138072) joint_offset = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -2.47238e-07, 6.31264e-08, 0.138072)
body_offset = Transform3D(100, 2.86102e-05, -3.8147e-05, -3.8147e-05, -1.90735e-06, -100, -3.8147e-06, 100, 1.14441e-05, 3.05176e-05, 13.8072, -1.52588e-05) body_offset = Transform3D(100, 3.05176e-05, -4.19617e-05, -3.8147e-05, 0, -100, -3.8147e-06, 100, 9.53674e-06, 3.05176e-05, 13.8072, -7.62939e-06)
mass = 3.0 mass = 3.0
bone_name = "mixamorig_LeftForeArm" bone_name = "mixamorig_LeftForeArm"
joint_constraints/bias = 0.3 joint_constraints/bias = 0.3
@ -1504,11 +1504,11 @@ transform = Transform3D(0.01, 0, 0, 0, -4.37114e-10, 0.01, 0, -0.01, -4.37114e-1
shape = SubResource("CapsuleShape3D_2k34c") shape = SubResource("CapsuleShape3D_2k34c")
[node name="Physical Bone mixamorig_LeftHand" type="PhysicalBone3D" parent="Body/Armature/Skeleton3D/PhysicalBoneSimulator3D"] [node name="Physical Bone mixamorig_LeftHand" type="PhysicalBone3D" parent="Body/Armature/Skeleton3D/PhysicalBoneSimulator3D"]
transform = Transform3D(9.11563, -98.6768, 13.4089, 23.9481, -10.8976, -96.4766, 96.6612, 12.0056, 22.6379, -10.9685, 56.2242, -106.442) transform = Transform3D(9.11563, -98.6768, 13.4089, 23.9481, -10.8976, -96.4766, 96.6612, 12.0056, 22.6379, -10.9684, 56.2242, -106.442)
collision_layer = 4 collision_layer = 4
collision_mask = 4 collision_mask = 4
joint_type = 1 joint_type = 1
joint_offset = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1.24797e-07, -1.22003e-07, 0.0264902) joint_offset = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -8.19564e-08, -9.40636e-08, 0.0264903)
body_offset = Transform3D(-58.5197, 57.9894, 56.6805, 1.62125e-05, 69.899, -71.5132, -81.0891, -41.8493, -40.9047, -1.50148, 1.89441, 1.08356) body_offset = Transform3D(-58.5197, 57.9894, 56.6805, 1.62125e-05, 69.899, -71.5132, -81.0891, -41.8493, -40.9047, -1.50148, 1.89441, 1.08356)
bone_name = "mixamorig_LeftHand" bone_name = "mixamorig_LeftHand"
joint_constraints/bias = 0.3 joint_constraints/bias = 0.3
@ -1524,8 +1524,8 @@ transform = Transform3D(30.7246, 72.8896, 61.1809, 93.7855, -34.092, -6.48192, 1
collision_layer = 4 collision_layer = 4
collision_mask = 4 collision_mask = 4
joint_type = 1 joint_type = 1
joint_offset = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1.50277e-08, 1.15999e-07, 0.137023) joint_offset = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1.63344e-08, 1.16325e-07, 0.137023)
body_offset = Transform3D(100, -5.72205e-06, 1.09673e-05, 6.67572e-06, 1.07288e-05, -100, -1.90735e-06, 100, 2.67029e-05, 0, 13.7023, -1.52588e-05) body_offset = Transform3D(100, -5.72205e-06, 1.19209e-05, 6.67572e-06, 1.07288e-05, -100, -1.90735e-06, 100, 2.64645e-05, 0, 13.7023, -1.52588e-05)
mass = 3.0 mass = 3.0
bone_name = "mixamorig_RightArm" bone_name = "mixamorig_RightArm"
joint_constraints/bias = 0.3 joint_constraints/bias = 0.3
@ -1537,12 +1537,12 @@ transform = Transform3D(0.01, 0, 0, 0, -4.37114e-10, 0.01, 0, -0.01, -4.37114e-1
shape = SubResource("CapsuleShape3D_8vkyv") shape = SubResource("CapsuleShape3D_8vkyv")
[node name="Physical Bone mixamorig_RightForeArm" type="PhysicalBone3D" parent="Body/Armature/Skeleton3D/PhysicalBoneSimulator3D"] [node name="Physical Bone mixamorig_RightForeArm" type="PhysicalBone3D" parent="Body/Armature/Skeleton3D/PhysicalBoneSimulator3D"]
transform = Transform3D(24.3552, 37.4063, 89.4852, -25.0101, 91.5653, -31.4688, -93.7087, -14.716, 31.6563, -48.2682, 3.93749, -103.698) transform = Transform3D(24.3552, 37.4063, 89.4852, -25.0101, 91.5653, -31.4688, -93.7087, -14.716, 31.6563, -48.2682, 3.93748, -103.698)
collision_layer = 4 collision_layer = 4
collision_mask = 4 collision_mask = 4
joint_type = 1 joint_type = 1
joint_offset = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 1.38762e-07, -5.86307e-09, 0.138072) joint_offset = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 1.40737e-07, -2.80687e-08, 0.138072)
body_offset = Transform3D(100, -9.53674e-06, 1.00136e-05, -3.8147e-06, 100, 3.8147e-06, 5.72205e-06, -5.72205e-06, 100, -1.52588e-05, 5.96046e-08, -13.8072) body_offset = Transform3D(100, -1.14441e-05, 8.58307e-06, -3.8147e-06, 100, 9.53674e-06, 5.72205e-06, -5.72205e-06, 100, -1.52588e-05, 1.49012e-06, -13.8072)
mass = 3.0 mass = 3.0
bone_name = "mixamorig_RightForeArm" bone_name = "mixamorig_RightForeArm"
joint_constraints/bias = 0.3 joint_constraints/bias = 0.3
@ -1558,8 +1558,8 @@ transform = Transform3D(89.0767, -24.8074, -38.0781, 5.05123, 88.6726, -45.9527,
collision_layer = 4 collision_layer = 4
collision_mask = 4 collision_mask = 4
joint_type = 1 joint_type = 1
joint_offset = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 1.86265e-08, 2.31434e-07, 0.0264903) joint_offset = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -6.51926e-09, 2.76137e-07, 0.0264903)
body_offset = Transform3D(-58.5197, -57.9893, -56.6805, -1.04904e-05, 69.8991, -71.5131, 81.0891, -41.8492, -40.9048, 1.5015, 1.89439, 1.08359) body_offset = Transform3D(-58.5197, -57.9893, -56.6805, -1.19209e-05, 69.8991, -71.5131, 81.0891, -41.8492, -40.9048, 1.5015, 1.89439, 1.08359)
bone_name = "mixamorig_RightHand" bone_name = "mixamorig_RightHand"
joint_constraints/bias = 0.3 joint_constraints/bias = 0.3
joint_constraints/damping = 1.0 joint_constraints/damping = 1.0
@ -1570,12 +1570,12 @@ transform = Transform3D(0.01, 0, 0, 0, 0.00693402, 0.00720551, 0, -0.00720551, 0
shape = SubResource("CapsuleShape3D_1m8r5") shape = SubResource("CapsuleShape3D_1m8r5")
[node name="Physical Bone mixamorig_LeftUpLeg" type="PhysicalBone3D" parent="Body/Armature/Skeleton3D/PhysicalBoneSimulator3D"] [node name="Physical Bone mixamorig_LeftUpLeg" type="PhysicalBone3D" parent="Body/Armature/Skeleton3D/PhysicalBoneSimulator3D"]
transform = Transform3D(-96.1774, -26.2684, 7.73901, -23.4203, 64.2554, -72.957, 14.1919, -71.9807, -67.9513, 5.83707, 19.601, -60.9754) transform = Transform3D(-96.1773, -26.2683, 7.73901, -23.4203, 64.2554, -72.957, 14.1919, -71.9807, -67.9513, 5.83707, 19.601, -60.9754)
collision_layer = 4 collision_layer = 4
collision_mask = 4 collision_mask = 4
joint_type = 1 joint_type = 1
joint_offset = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 3.78612e-08, -7.74374e-09, 0.202997) joint_offset = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 3.78612e-08, -7.74373e-09, 0.202997)
body_offset = Transform3D(100, -2.67029e-05, 9.53674e-06, 5.72205e-06, 7.62939e-06, -100, 3.33786e-05, 100, 3.8147e-06, -5.72205e-06, 20.2997, 0) body_offset = Transform3D(100, -2.86102e-05, 9.53674e-06, 7.62939e-06, 7.62939e-06, -100, 3.71933e-05, 100, 3.8147e-06, -5.72205e-06, 20.2997, 0)
mass = 5.0 mass = 5.0
bone_name = "mixamorig_LeftUpLeg" bone_name = "mixamorig_LeftUpLeg"
joint_constraints/bias = 0.3 joint_constraints/bias = 0.3
@ -1591,8 +1591,8 @@ transform = Transform3D(-97.5216, -11.6193, -18.8291, -22.0483, 58.1427, 78.3154
collision_layer = 4 collision_layer = 4
collision_mask = 4 collision_mask = 4
joint_type = 1 joint_type = 1
joint_offset = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -5.01576e-09, -2.10753e-08, 0.210495) joint_offset = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -9.03062e-09, -1.30455e-08, 0.210495)
body_offset = Transform3D(100, 4.76837e-06, 1.14441e-05, 5.72205e-06, 0, -100, -9.53674e-07, 100, 1.90735e-05, -1.90735e-06, 21.0495, -1.90735e-06) body_offset = Transform3D(100, 4.76837e-06, 1.33514e-05, 5.72205e-06, 0, -100, -9.53674e-07, 100, 1.52588e-05, -1.90735e-06, 21.0495, -1.90735e-06)
mass = 5.0 mass = 5.0
bone_name = "mixamorig_LeftLeg" bone_name = "mixamorig_LeftLeg"
joint_constraints/bias = 0.3 joint_constraints/bias = 0.3
@ -1608,8 +1608,8 @@ transform = Transform3D(-93.6712, -34.5296, 5.78095, -34.9451, 91.207, -21.4506,
collision_layer = 4 collision_layer = 4
collision_mask = 4 collision_mask = 4
joint_type = 1 joint_type = 1
joint_offset = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -6.53808e-09, 5.17146e-08, 0.078608) joint_offset = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -7.66258e-09, 5.6483e-08, 0.078608)
body_offset = Transform3D(100, 5.72205e-06, -3.8147e-06, -3.8147e-06, -1.52588e-05, -100, -5.72205e-06, 100, -3.24249e-05, 9.53674e-07, 7.8608, -2.6226e-06) body_offset = Transform3D(100, 5.72205e-06, -2.38419e-06, -2.86102e-06, -1.52588e-05, -100, -5.72205e-06, 100, -3.24249e-05, 9.53674e-07, 7.8608, -3.09944e-06)
bone_name = "mixamorig_LeftFoot" bone_name = "mixamorig_LeftFoot"
joint_constraints/bias = 0.3 joint_constraints/bias = 0.3
joint_constraints/damping = 1.0 joint_constraints/damping = 1.0
@ -1624,8 +1624,8 @@ transform = Transform3D(-83.6898, -51.5224, 18.4786, -50.5592, 59.8312, -62.161,
collision_layer = 4 collision_layer = 4
collision_mask = 4 collision_mask = 4
joint_type = 1 joint_type = 1
joint_offset = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 2.08665e-08, 7.74372e-09, 0.202997) joint_offset = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 1.31228e-08, 7.74372e-09, 0.202997)
body_offset = Transform3D(100, -1.52588e-05, 3.8147e-06, 5.72205e-06, -3.8147e-06, -100, 1.14441e-05, 100, -3.8147e-06, -2.86102e-06, 20.2997, 0) body_offset = Transform3D(100, -1.52588e-05, 7.62939e-06, 5.72205e-06, -3.8147e-06, -100, 1.14441e-05, 100, -3.8147e-06, -2.86102e-06, 20.2997, 0)
mass = 5.0 mass = 5.0
bone_name = "mixamorig_RightUpLeg" bone_name = "mixamorig_RightUpLeg"
joint_constraints/bias = 0.3 joint_constraints/bias = 0.3
@ -1641,8 +1641,8 @@ transform = Transform3D(-91.8175, -23.5086, -31.8888, -36.0103, 83.0805, 42.437,
collision_layer = 4 collision_layer = 4
collision_mask = 4 collision_mask = 4
joint_type = 1 joint_type = 1
joint_offset = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 5.06137e-10, -2.07784e-07, 0.210495) joint_offset = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 5.27445e-09, -2.4944e-07, 0.210495)
body_offset = Transform3D(100, -1.52588e-05, 1.33514e-05, -9.53674e-07, 3.8147e-05, -100, 1.90735e-05, 100, 5.34058e-05, -2.86102e-06, 21.0495, 9.53674e-06) body_offset = Transform3D(100, -1.71661e-05, 1.33514e-05, -9.53674e-07, 4.19617e-05, -100, 1.90735e-05, 100, 6.86646e-05, -3.33786e-06, 21.0495, 1.04904e-05)
mass = 5.0 mass = 5.0
bone_name = "mixamorig_RightLeg" bone_name = "mixamorig_RightLeg"
joint_constraints/bias = 0.3 joint_constraints/bias = 0.3
@ -1658,7 +1658,7 @@ transform = Transform3D(-88.192, -17.3351, 43.8367, -46.8549, 42.4444, -77.4796,
collision_layer = 4 collision_layer = 4
collision_mask = 4 collision_mask = 4
joint_type = 1 joint_type = 1
joint_offset = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -5.24153e-08, -2.70381e-09, 0.078608) joint_offset = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -5.24152e-08, -2.70387e-09, 0.078608)
body_offset = Transform3D(100, 1.14441e-05, -7.62939e-06, -7.62939e-06, -1.90735e-05, -100, 0, 100, -5.72205e-05, 5.84126e-06, 7.8608, 4.76837e-06) body_offset = Transform3D(100, 1.14441e-05, -7.62939e-06, -7.62939e-06, -1.90735e-05, -100, 0, 100, -5.72205e-05, 5.84126e-06, 7.8608, 4.76837e-06)
bone_name = "mixamorig_RightFoot" bone_name = "mixamorig_RightFoot"
joint_constraints/bias = 0.3 joint_constraints/bias = 0.3

View File

@ -1,8 +1,8 @@
extends Area3D extends Area3D
@export var damage: int = 20 @export var damage_multiplexer: float = 2.0
signal body_part_hit(dam) signal body_part_hit(damage: int)
# Called when the node enters the scene tree for the first time. # Called when the node enters the scene tree for the first time.
func _ready() -> void: func _ready() -> void:
@ -12,5 +12,6 @@ func _ready() -> void:
func _process(delta: float) -> void: func _process(delta: float) -> void:
pass pass
func hit(): func hit(base_damage: int):
emit_signal("body_part_hit", damage) var final_damage = round(base_damage * damage_multiplexer)
emit_signal("body_part_hit", final_damage)

View File

@ -26,12 +26,15 @@ func _ready() -> void:
$MultiplayerSpawner.spawn(char) $MultiplayerSpawner.spawn(char)
players.add_child(char) players.add_child(char)
var bullet_amount: int = 0 var bullet_amount: int = 0
func spawn_bullet(position): func spawn_bullet(starting_point: Node3D, speed: int, damage: int):
var node: Node3D = ResourceLoader.load("res://scenes/weapon/bullet.tscn").instantiate() var node: Node3D = ResourceLoader.load("res://scenes/weapon/bullet.tscn").instantiate()
node.position = position.global_position node.position = starting_point.global_position
node.transform.basis = position.global_transform.basis node.transform.basis = starting_point.global_transform.basis
node.name = str(bullet_amount) node.name = str(bullet_amount)
node.speed = speed
node.damage = damage
bullet_amount += 1 bullet_amount += 1
#$BulletSpawner.spawn(node) #$BulletSpawner.spawn(node)
$Bullets.add_child(node) $Bullets.add_child(node)

View File

@ -1,7 +1,7 @@
extends Node3D extends Node3D
const SPEED = 200 # 200 @export var speed: int = 0
@export var damage: int = 0
@onready var mesh = $RigidBody3D/MeshInstance3D @onready var mesh = $RigidBody3D/MeshInstance3D
@onready var rigid_body_3d: RigidBody3D = $RigidBody3D @onready var rigid_body_3d: RigidBody3D = $RigidBody3D
@onready var ray = $RigidBody3D/RayCast3D @onready var ray = $RigidBody3D/RayCast3D
@ -15,9 +15,9 @@ func _ready() -> void:
# Called every frame. 'delta' is the elapsed time since the previous frame. # Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta): func _process(delta):
var time_per_frame: float = 1 / Engine.get_frames_per_second() var time_per_frame: float = 1 / Engine.get_frames_per_second()
var distance: float = time_per_frame * SPEED * 1.5 var distance: float = time_per_frame * speed * 1.5
ray.target_position.z = distance ray.target_position.z = distance
position += transform.basis * Vector3(0, 0, SPEED) * delta position += transform.basis * Vector3(0, 0, speed) * delta
rigid_body_3d.set_use_continuous_collision_detection(true) rigid_body_3d.set_use_continuous_collision_detection(true)
#ray.collision_mask = 1 #ray.collision_mask = 1
#ray.enabled = 1 #ray.enabled = 1
@ -26,7 +26,7 @@ func _process(delta):
if collider != null and collider.is_in_group("target"): if collider != null and collider.is_in_group("target"):
ray.get_collider().take_damage() ray.get_collider().take_damage()
if collider != null and collider.is_in_group("body"): if collider != null and collider.is_in_group("body"):
ray.get_collider().hit() ray.get_collider().hit(damage)
rigid_body_3d.visible = false rigid_body_3d.visible = false
particles.emitting = true particles.emitting = true
#if ray.get_collider().is_in_group("body"): #if ray.get_collider().is_in_group("body"):

View File

@ -0,0 +1,41 @@
extends Node3D
# ---------------------------------------------------------------------
# Main weapon params
# ---------------------------------------------------------------------
@export var damage: int = 0
# cooldown interval in seconds
@export var cooldown: float = 0
# bullet speed in m/s
@export var bullet_speed: int = 0
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
pass # Replace with function body.
@onready var bullet_trace_distance: Node3D = $BulletTraceDistance
@onready var bullet_trail_end: Node3D = $BulletTrailEnd
func shoot() -> Error:
var bullet_start_node: Node3D = bullet_trace_distance.find_child("Start")
var bullet_end_node: Node3D = bullet_trace_distance.find_child("End")
if bullet_start_node and bullet_end_node:
var path := "res://scenes/weapon/misc/bullet_trail_generic.tscn"
if not ResourceLoader.exists(path):
return ERR_DOES_NOT_EXIST
var scene: PackedScene = ResourceLoader.load(path)
if not scene.can_instantiate():
return ERR_CANT_OPEN
var node: MeshInstance3D = scene.instantiate()
node.init(bullet_start_node.position, bullet_end_node.position)
#var root := get_tree().get_root()
bullet_start_node.add_child(node)
return OK
else:
push_warning("Couldn't generate a bullet trace, no distance node found")
return ERR_BUG
# -- TODO: It should not be hardcoded
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
pass

View File

@ -1,18 +0,0 @@
extends Node3D
const SPEED = 10
@onready var mesh = $Object_10
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
position += transform.basis * Vector3(0, 0, SPEED) * delta
func _on_timer_timeout():
queue_free()

View File

@ -1,6 +1,4 @@
[gd_scene load_steps=5 format=4 uid="uid://dn6imke7vnimn"] [gd_scene load_steps=4 format=4 uid="uid://dn6imke7vnimn"]
[ext_resource type="Script" path="res://scenes/weapon/guns/ak/bullet.gd" id="1_rbbkb"]
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_ledbj"] [sub_resource type="StandardMaterial3D" id="StandardMaterial3D_ledbj"]
resource_name = "stell" resource_name = "stell"
@ -45,7 +43,6 @@ shadow_mesh = SubResource("ArrayMesh_mgmay")
[node name="Bullet" type="Node3D"] [node name="Bullet" type="Node3D"]
transform = Transform3D(10, 0, 0, 0, 10, 0, 0, 0, 10, 0, 0, 0) transform = Transform3D(10, 0, 0, 0, 10, 0, 0, 0, 10, 0, 0, 0)
script = ExtResource("1_rbbkb")
[node name="Object_10" type="MeshInstance3D" parent="."] [node name="Object_10" 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)

View File

@ -1,10 +0,0 @@
extends MeshInstance3D
var trail_length = 2.0
var speed = 10.0
func _process(delta):
global_transform.origin += transform.basis.z * speed * delta
scale.x = max(scale.x - delta, 100)
scale.y = max(scale.y - delta, 100)
scale.z = max(scale.z - delta, 100)

View File

@ -1,7 +1,7 @@
[gd_scene load_steps=55 format=4 uid="uid://dtvo21mk1webd"] [gd_scene load_steps=55 format=4 uid="uid://dtvo21mk1webd"]
[ext_resource type="Script" path="res://scenes/weapon/guns/ak/with_hands.gd" id="1_2iqts"]
[ext_resource type="PackedScene" uid="uid://dab7jttp7ywfh" path="res://scenes/weapon/guns/ak/gun.tscn" id="1_aaafm"] [ext_resource type="PackedScene" uid="uid://dab7jttp7ywfh" path="res://scenes/weapon/guns/ak/gun.tscn" id="1_aaafm"]
[ext_resource type="Script" path="res://scenes/weapon/generic_weapon_controller.gd" id="1_h1xyo"]
[ext_resource type="PackedScene" uid="uid://bjyltbtx45cqs" path="res://scenes/weapon/misc/bullet_trace_distance.tscn" id="3_5ff4y"] [ext_resource type="PackedScene" uid="uid://bjyltbtx45cqs" path="res://scenes/weapon/misc/bullet_trace_distance.tscn" id="3_5ff4y"]
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_tg27p"] [sub_resource type="StandardMaterial3D" id="StandardMaterial3D_tg27p"]
@ -553,7 +553,10 @@ blend_shape_mode = 0
shadow_mesh = SubResource("ArrayMesh_he3sr") shadow_mesh = SubResource("ArrayMesh_he3sr")
[node name="WithHands" type="Node3D"] [node name="WithHands" type="Node3D"]
script = ExtResource("1_2iqts") script = ExtResource("1_h1xyo")
damage = 50
cooldown = 0.2
bullet_speed = 200
[node name="Gun" parent="." instance=ExtResource("1_aaafm")] [node name="Gun" parent="." instance=ExtResource("1_aaafm")]

View File

@ -107,6 +107,9 @@ func _add_first_view_model() -> Error :
var node: Node3D = scene.instantiate() var node: Node3D = scene.instantiate()
node.scale = Vector3(0.03,0.03,0.03) node.scale = Vector3(0.03,0.03,0.03)
node.position = Vector3(0.02, -0.03, -0.07) node.position = Vector3(0.02, -0.03, -0.07)
current_weapon_bullet_speed = node.bullet_speed
current_weapon_cooldown_interwal = node.cooldown
current_weapon_damage = node.damage
gun_with_hands = node gun_with_hands = node
gun_mount.add_child(node) gun_mount.add_child(node)
return OK return OK
@ -237,6 +240,9 @@ var bullet = load("res://scenes/weapon/bullet.tscn")
@onready var shooting_raycast: RayCast3D = $FirstPersonCameraMount/RayCast3D @onready var shooting_raycast: RayCast3D = $FirstPersonCameraMount/RayCast3D
@onready var bullet_starting_point: Node3D = $FirstPersonCameraMount/BulletStartingPoint @onready var bullet_starting_point: Node3D = $FirstPersonCameraMount/BulletStartingPoint
@onready var aim_ray: RayCast3D = $FirstPersonCameraMount/BulletStartingPoint/AimRay @onready var aim_ray: RayCast3D = $FirstPersonCameraMount/BulletStartingPoint/AimRay
var current_weapon_damage: int
var current_weapon_bullet_speed: int
var current_weapon_cooldown_interwal: float
# --find the gun node and exec shoot # --find the gun node and exec shoot
var cant_shoot: bool = false var cant_shoot: bool = false
func _shoot(): func _shoot():
@ -247,18 +253,18 @@ func _shoot():
if collider != null and collider.is_in_group("target"): if collider != null and collider.is_in_group("target"):
aim_ray.get_collider().take_damage() aim_ray.get_collider().take_damage()
if collider != null and collider.is_in_group("body"): if collider != null and collider.is_in_group("body"):
collider.hit() collider.hit(50)
var root := get_tree().get_root() var root := get_tree().get_root()
gun_with_hands.shoot() gun_with_hands.shoot()
cant_shoot = true cant_shoot = true
await get_tree().create_timer(0.2).timeout await get_tree().create_timer(current_weapon_cooldown_interwal).timeout
cant_shoot = false cant_shoot = false
@rpc("any_peer", "call_local", "unreliable_ordered") @rpc("any_peer", "call_local", "unreliable_ordered")
func _send_shot_to_server(start_position): func _send_shot_to_server(start_position):
# -- TODO: Should not be hardcoded # -- TODO: Should not be hardcoded
var world: Node3D = find_parent("ElTest") var world: Node3D = find_parent("ElTest")
world.spawn_bullet(bullet_starting_point) world.spawn_bullet(bullet_starting_point, current_weapon_bullet_speed, current_weapon_damage)
func _get_camera_collision(): func _get_camera_collision():
var viewport = get_viewport().size var viewport = get_viewport().size