Compare commits
12 Commits
implement-
...
5c360932fd
Author | SHA1 | Date | |
---|---|---|---|
5c360932fd
|
|||
c7c577233b
|
|||
5678ddb4c1
|
|||
24914cb6fa
|
|||
c2a5f9cf1c
|
|||
66efa9ec99
|
|||
dbfcf573c2
|
|||
ed53f156c0
|
|||
fa09a1dde1
|
|||
d2b89c9d5c
|
|||
e28845b688
|
|||
adce112be9
|
@ -13,6 +13,7 @@ config_version=5
|
|||||||
config/name="Open Strike"
|
config/name="Open Strike"
|
||||||
run/main_scene="res://scenes/utils/Menu.tscn"
|
run/main_scene="res://scenes/utils/Menu.tscn"
|
||||||
config/features=PackedStringArray("4.3", "Forward Plus")
|
config/features=PackedStringArray("4.3", "Forward Plus")
|
||||||
|
run/max_fps=120
|
||||||
config/icon="res://icon.svg"
|
config/icon="res://icon.svg"
|
||||||
|
|
||||||
[autoload]
|
[autoload]
|
||||||
@ -25,6 +26,7 @@ window/size/viewport_width=1920
|
|||||||
window/size/viewport_height=1964
|
window/size/viewport_height=1964
|
||||||
window/size/mode=4
|
window/size/mode=4
|
||||||
window/size/borderless=true
|
window/size/borderless=true
|
||||||
|
window/vsync/vsync_mode=2
|
||||||
|
|
||||||
[filesystem]
|
[filesystem]
|
||||||
|
|
||||||
@ -34,6 +36,7 @@ import/blender/enabled=false
|
|||||||
|
|
||||||
body=""
|
body=""
|
||||||
target=""
|
target=""
|
||||||
|
player_placeholder=""
|
||||||
|
|
||||||
[input]
|
[input]
|
||||||
|
|
||||||
|
@ -1,8 +1,11 @@
|
|||||||
extends Node3D
|
extends Node3D
|
||||||
|
|
||||||
|
|
||||||
|
var owner_placeholder: CharacterBody3D = null
|
||||||
# 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:
|
||||||
|
print("ready")
|
||||||
|
owner_placeholder = _get_owner()
|
||||||
pass # Replace with function body.
|
pass # Replace with function body.
|
||||||
|
|
||||||
|
|
||||||
@ -12,5 +15,13 @@ func _process(delta: float) -> void:
|
|||||||
|
|
||||||
|
|
||||||
func _on_head_collision_body_part_hit(dam: Variant) -> void:
|
func _on_head_collision_body_part_hit(dam: Variant) -> void:
|
||||||
print("head is hit")
|
#print("head is hit" + str(dam))
|
||||||
|
#print(owner_placeholder)
|
||||||
|
#if owner_placeholder.has_method("take_damage"):
|
||||||
|
owner_placeholder.take_damage(dam)
|
||||||
pass # Replace with function body.
|
pass # Replace with function body.
|
||||||
|
|
||||||
|
func _get_owner() -> CharacterBody3D:
|
||||||
|
var owner_placeholder := find_parent("PlayerPlaceholder*")
|
||||||
|
return owner_placeholder
|
||||||
|
|
||||||
|
@ -1048,7 +1048,7 @@ bones/24/name = "mixamorig_LeftHandRing2"
|
|||||||
bones/24/parent = 23
|
bones/24/parent = 23
|
||||||
bones/24/rest = Transform3D(1, 1.61871e-05, -9.45085e-08, -1.61871e-05, 1, 3.29224e-06, 9.45618e-08, -3.29224e-06, 1, 6.3543e-07, 3.60118, -1.47875e-05)
|
bones/24/rest = Transform3D(1, 1.61871e-05, -9.45085e-08, -1.61871e-05, 1, 3.29224e-06, 9.45618e-08, -3.29224e-06, 1, 6.3543e-07, 3.60118, -1.47875e-05)
|
||||||
bones/24/enabled = true
|
bones/24/enabled = true
|
||||||
bones/24/position = Vector3(-3.30613e-06, 3.60119, 1.50863e-07)
|
bones/24/position = Vector3(-3.30613e-06, 3.60119, 1.50864e-07)
|
||||||
bones/24/rotation = Quaternion(0.563924, -3.30111e-07, -0.0577891, 0.823803)
|
bones/24/rotation = Quaternion(0.563924, -3.30111e-07, -0.0577891, 0.823803)
|
||||||
bones/24/scale = Vector3(1, 1, 1)
|
bones/24/scale = Vector3(1, 1, 1)
|
||||||
bones/25/name = "mixamorig_LeftHandRing3"
|
bones/25/name = "mixamorig_LeftHandRing3"
|
||||||
@ -1077,7 +1077,7 @@ bones/28/parent = 27
|
|||||||
bones/28/rest = Transform3D(1, 0.000736602, -7.57697e-07, -0.000736602, 1, 9.24707e-06, 7.64508e-07, -9.24651e-06, 1, 1.0844e-06, 4.13666, 1.41886e-05)
|
bones/28/rest = Transform3D(1, 0.000736602, -7.57697e-07, -0.000736602, 1, 9.24707e-06, 7.64508e-07, -9.24651e-06, 1, 1.0844e-06, 4.13666, 1.41886e-05)
|
||||||
bones/28/enabled = true
|
bones/28/enabled = true
|
||||||
bones/28/position = Vector3(-9.08385e-06, 4.13665, 5.47372e-06)
|
bones/28/position = Vector3(-9.08385e-06, 4.13665, 5.47372e-06)
|
||||||
bones/28/rotation = Quaternion(0.433129, -6.53828e-07, -0.0443853, 0.900239)
|
bones/28/rotation = Quaternion(0.433129, -6.53827e-07, -0.0443853, 0.900239)
|
||||||
bones/28/scale = Vector3(1, 1, 1)
|
bones/28/scale = Vector3(1, 1, 1)
|
||||||
bones/29/name = "mixamorig_LeftHandPinky3"
|
bones/29/name = "mixamorig_LeftHandPinky3"
|
||||||
bones/29/parent = 28
|
bones/29/parent = 28
|
||||||
@ -1126,7 +1126,7 @@ bones/35/parent = 34
|
|||||||
bones/35/rest = Transform3D(0.894428, 0.447212, -8.12113e-07, -0.387297, 0.774597, -0.500001, -0.223606, 0.447215, 0.866025, 3.00297, 3.7888, 2.16716)
|
bones/35/rest = Transform3D(0.894428, 0.447212, -8.12113e-07, -0.387297, 0.774597, -0.500001, -0.223606, 0.447215, 0.866025, 3.00297, 3.7888, 2.16716)
|
||||||
bones/35/enabled = true
|
bones/35/enabled = true
|
||||||
bones/35/position = Vector3(3.00297, 3.7888, 2.16716)
|
bones/35/position = Vector3(3.00297, 3.7888, 2.16716)
|
||||||
bones/35/rotation = Quaternion(0.227577, -0.0598799, -0.162411, 0.958252)
|
bones/35/rotation = Quaternion(0.227577, -0.0598799, -0.162411, 0.958251)
|
||||||
bones/35/scale = Vector3(1, 1, 1)
|
bones/35/scale = Vector3(1, 1, 1)
|
||||||
bones/36/name = "mixamorig_RightHandThumb2"
|
bones/36/name = "mixamorig_RightHandThumb2"
|
||||||
bones/36/parent = 35
|
bones/36/parent = 35
|
||||||
@ -1210,14 +1210,14 @@ bones/47/parent = 34
|
|||||||
bones/47/rest = Transform3D(1, 9.66599e-06, -1.40744e-07, -9.66599e-06, 1, -2.81994e-06, 1.40717e-07, 2.81994e-06, 1, -2.21663, 12.147, -0.00999829)
|
bones/47/rest = Transform3D(1, 9.66599e-06, -1.40744e-07, -9.66599e-06, 1, -2.81994e-06, 1.40717e-07, 2.81994e-06, 1, -2.21663, 12.147, -0.00999829)
|
||||||
bones/47/enabled = true
|
bones/47/enabled = true
|
||||||
bones/47/position = Vector3(-2.21664, 12.147, -0.00998812)
|
bones/47/position = Vector3(-2.21664, 12.147, -0.00998812)
|
||||||
bones/47/rotation = Quaternion(0.0911117, 0.11369, 0.100504, 0.984211)
|
bones/47/rotation = Quaternion(0.0911117, 0.11369, 0.100504, 0.984212)
|
||||||
bones/47/scale = Vector3(1, 1, 1)
|
bones/47/scale = Vector3(1, 1, 1)
|
||||||
bones/48/name = "mixamorig_RightHandRing2"
|
bones/48/name = "mixamorig_RightHandRing2"
|
||||||
bones/48/parent = 47
|
bones/48/parent = 47
|
||||||
bones/48/rest = Transform3D(1, -1.60845e-05, 3.26056e-09, 1.60845e-05, 1, 1.32059e-06, -3.2818e-09, -1.32059e-06, 1, -2.50026e-07, 3.6012, -7.75122e-07)
|
bones/48/rest = Transform3D(1, -1.60845e-05, 3.26056e-09, 1.60845e-05, 1, 1.32059e-06, -3.2818e-09, -1.32059e-06, 1, -2.50026e-07, 3.6012, -7.75122e-07)
|
||||||
bones/48/enabled = true
|
bones/48/enabled = true
|
||||||
bones/48/position = Vector3(-2.50026e-07, 3.6012, -7.75122e-07)
|
bones/48/position = Vector3(-2.50026e-07, 3.6012, -7.75122e-07)
|
||||||
bones/48/rotation = Quaternion(0.836665, 8.70473e-07, 0.068157, 0.543457)
|
bones/48/rotation = Quaternion(0.836665, 8.70474e-07, 0.068157, 0.543457)
|
||||||
bones/48/scale = Vector3(1, 1, 1)
|
bones/48/scale = Vector3(1, 1, 1)
|
||||||
bones/49/name = "mixamorig_RightHandRing3"
|
bones/49/name = "mixamorig_RightHandRing3"
|
||||||
bones/49/parent = 48
|
bones/49/parent = 48
|
||||||
@ -1301,14 +1301,14 @@ bones/60/parent = 0
|
|||||||
bones/60/rest = Transform3D(-0.999981, -0.00611455, -7.52684e-05, 0.00611501, -0.999901, -0.0126672, 2.1931e-06, -0.0126674, 0.99992, -9.12503, -6.6556, -0.0553527)
|
bones/60/rest = Transform3D(-0.999981, -0.00611455, -7.52684e-05, 0.00611501, -0.999901, -0.0126672, 2.1931e-06, -0.0126674, 0.99992, -9.12503, -6.6556, -0.0553527)
|
||||||
bones/60/enabled = true
|
bones/60/enabled = true
|
||||||
bones/60/position = Vector3(-9.12503, -6.6556, -0.0553527)
|
bones/60/position = Vector3(-9.12503, -6.6556, -0.0553527)
|
||||||
bones/60/rotation = Quaternion(-0.0339456, 0.334676, 0.92684, -0.166754)
|
bones/60/rotation = Quaternion(-0.0339455, 0.334676, 0.92684, -0.166754)
|
||||||
bones/60/scale = Vector3(1, 1, 1)
|
bones/60/scale = Vector3(1, 1, 1)
|
||||||
bones/61/name = "mixamorig_RightLeg"
|
bones/61/name = "mixamorig_RightLeg"
|
||||||
bones/61/parent = 60
|
bones/61/parent = 60
|
||||||
bones/61/rest = Transform3D(0.99993, -0.0118315, -0.000580536, 0.0118448, 0.999271, 0.0362854, 0.000150802, -0.0362897, 0.999341, 3.28565e-07, 40.5995, 1.49012e-08)
|
bones/61/rest = Transform3D(0.99993, -0.0118315, -0.000580536, 0.0118448, 0.999271, 0.0362854, 0.000150802, -0.0362897, 0.999341, 3.28565e-07, 40.5995, 1.49012e-08)
|
||||||
bones/61/enabled = true
|
bones/61/enabled = true
|
||||||
bones/61/position = Vector3(3.28565e-07, 40.5995, 1.49012e-08)
|
bones/61/position = Vector3(3.28565e-07, 40.5995, 1.49012e-08)
|
||||||
bones/61/rotation = Quaternion(-0.581827, -0.0846291, -0.0166473, 0.808727)
|
bones/61/rotation = Quaternion(-0.581827, -0.0846291, -0.0166473, 0.808726)
|
||||||
bones/61/scale = Vector3(1, 1, 1)
|
bones/61/scale = Vector3(1, 1, 1)
|
||||||
bones/62/name = "mixamorig_RightFoot"
|
bones/62/name = "mixamorig_RightFoot"
|
||||||
bones/62/parent = 61
|
bones/62/parent = 61
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
extends Area3D
|
extends Area3D
|
||||||
|
|
||||||
@export var damage: int = 100
|
@export var damage: int = 20
|
||||||
|
|
||||||
signal body_part_hit(dam)
|
signal body_part_hit(dam)
|
||||||
# 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:
|
||||||
pass # Replace with function body.
|
pass # Replace with function body.
|
||||||
|
|
||||||
|
|
||||||
# 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: float) -> void:
|
func _process(delta: float) -> void:
|
||||||
pass
|
pass
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
[gd_scene load_steps=9 format=3 uid="uid://b10lpwfjgxds4"]
|
[gd_scene load_steps=11 format=3 uid="uid://b10lpwfjgxds4"]
|
||||||
|
|
||||||
[ext_resource type="Script" path="res://scripts/player/player_input_controller.gd" id="1_q75ai"]
|
[ext_resource type="Script" path="res://scripts/player/player_input_controller.gd" id="1_q75ai"]
|
||||||
[ext_resource type="Texture2D" uid="uid://oopj5mj1vdp0" path="res://assets/crosshairs/crosshair_default.png" id="2_lsd7c"]
|
[ext_resource type="Texture2D" uid="uid://oopj5mj1vdp0" path="res://assets/crosshairs/crosshair_default.png" id="2_lsd7c"]
|
||||||
@ -14,6 +14,9 @@ properties/0/replication_mode = 1
|
|||||||
properties/1/path = NodePath(".:rotation")
|
properties/1/path = NodePath(".:rotation")
|
||||||
properties/1/spawn = true
|
properties/1/spawn = true
|
||||||
properties/1/replication_mode = 1
|
properties/1/replication_mode = 1
|
||||||
|
properties/2/path = NodePath(".:health")
|
||||||
|
properties/2/spawn = true
|
||||||
|
properties/2/replication_mode = 2
|
||||||
|
|
||||||
[sub_resource type="Animation" id="Animation_falg4"]
|
[sub_resource type="Animation" id="Animation_falg4"]
|
||||||
length = 0.001
|
length = 0.001
|
||||||
@ -72,6 +75,13 @@ _data = {
|
|||||||
"shooting": SubResource("Animation_ah507")
|
"shooting": SubResource("Animation_ah507")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[sub_resource type="LabelSettings" id="LabelSettings_toaij"]
|
||||||
|
font_size = 70
|
||||||
|
|
||||||
|
[sub_resource type="LabelSettings" id="LabelSettings_1j1uq"]
|
||||||
|
font_size = 100
|
||||||
|
font_color = Color(0.756874, 0, 0.223924, 1)
|
||||||
|
|
||||||
[node name="CharacterPlaceholder" type="CharacterBody3D"]
|
[node name="CharacterPlaceholder" type="CharacterBody3D"]
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.799455, 0)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.799455, 0)
|
||||||
collision_layer = 9
|
collision_layer = 9
|
||||||
@ -85,7 +95,7 @@ shape = SubResource("CapsuleShape3D_jc50w")
|
|||||||
replication_config = SubResource("SceneReplicationConfig_tl74a")
|
replication_config = SubResource("SceneReplicationConfig_tl74a")
|
||||||
|
|
||||||
[node name="FirstPersonCameraMount" type="Node3D" parent="."]
|
[node name="FirstPersonCameraMount" type="Node3D" parent="."]
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.609154, 0)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.609154, -0.209324)
|
||||||
|
|
||||||
[node name="Camera" type="Camera3D" parent="FirstPersonCameraMount"]
|
[node name="Camera" type="Camera3D" parent="FirstPersonCameraMount"]
|
||||||
fov = 40.0
|
fov = 40.0
|
||||||
@ -96,6 +106,7 @@ transform = Transform3D(-1, 0, -8.74228e-08, 0, 1, 0, 8.74228e-08, 0, -1, 0, 0,
|
|||||||
[node name="AimRay" type="RayCast3D" parent="FirstPersonCameraMount/BulletStartingPoint"]
|
[node name="AimRay" type="RayCast3D" parent="FirstPersonCameraMount/BulletStartingPoint"]
|
||||||
target_position = Vector3(0, 0, 1000)
|
target_position = Vector3(0, 0, 1000)
|
||||||
hit_from_inside = true
|
hit_from_inside = true
|
||||||
|
collide_with_areas = true
|
||||||
|
|
||||||
[node name="GunMount" type="Node3D" parent="FirstPersonCameraMount"]
|
[node name="GunMount" type="Node3D" parent="FirstPersonCameraMount"]
|
||||||
|
|
||||||
@ -105,6 +116,7 @@ libraries = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
[node name="HUD" type="Control" parent="FirstPersonCameraMount"]
|
[node name="HUD" type="Control" parent="FirstPersonCameraMount"]
|
||||||
|
visible = false
|
||||||
layout_mode = 3
|
layout_mode = 3
|
||||||
anchors_preset = 15
|
anchors_preset = 15
|
||||||
anchor_right = 1.0
|
anchor_right = 1.0
|
||||||
@ -130,5 +142,23 @@ grow_horizontal = 2
|
|||||||
grow_vertical = 2
|
grow_vertical = 2
|
||||||
texture = ExtResource("2_lsd7c")
|
texture = ExtResource("2_lsd7c")
|
||||||
|
|
||||||
|
[node name="HealthIndicator" type="Label" parent="FirstPersonCameraMount/HUD"]
|
||||||
|
layout_mode = 1
|
||||||
|
anchors_preset = 2
|
||||||
|
anchor_top = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
offset_top = -23.0
|
||||||
|
offset_right = 40.0
|
||||||
|
grow_vertical = 0
|
||||||
|
text = "100"
|
||||||
|
label_settings = SubResource("LabelSettings_toaij")
|
||||||
|
|
||||||
|
[node name="FPS" type="Label" parent="FirstPersonCameraMount/HUD" groups=["player_placeholder"]]
|
||||||
|
layout_mode = 1
|
||||||
|
offset_right = 40.0
|
||||||
|
offset_bottom = 23.0
|
||||||
|
text = "0"
|
||||||
|
label_settings = SubResource("LabelSettings_1j1uq")
|
||||||
|
|
||||||
[node name="ModelMount" type="Node3D" parent="."]
|
[node name="ModelMount" type="Node3D" parent="."]
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.790262, 0)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.790262, 0)
|
||||||
|
@ -2,8 +2,15 @@ extends CSGBox3D
|
|||||||
|
|
||||||
var health = 5
|
var health = 5
|
||||||
|
|
||||||
|
@export var color: Color = Color(0, 0, 0)
|
||||||
|
|
||||||
|
var colors = [Color(1.0, 0.0, 0.0, 1.0),
|
||||||
|
Color(0.0, 1.0, 0.0, 1.0),
|
||||||
|
Color(0.0, 0.0, 1.0, 0.0)]
|
||||||
|
|
||||||
func take_damage():
|
func take_damage():
|
||||||
health -= 1
|
color = Color(randf(), randf(), randf())
|
||||||
|
|
||||||
# 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:
|
||||||
pass # Replace with function body.
|
pass # Replace with function body.
|
||||||
@ -11,5 +18,6 @@ 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: float) -> void:
|
func _process(delta: float) -> void:
|
||||||
|
material_override.albedo_color = color
|
||||||
if health < 1:
|
if health < 1:
|
||||||
queue_free()
|
queue_free()
|
||||||
|
@ -16,7 +16,7 @@ func _ready() -> void:
|
|||||||
if multiplayer.is_server():
|
if multiplayer.is_server():
|
||||||
for i in GameServerManager.players:
|
for i in GameServerManager.players:
|
||||||
char = ResourceLoader.load("res://scenes/characters/placeholder.tscn").instantiate()
|
char = ResourceLoader.load("res://scenes/characters/placeholder.tscn").instantiate()
|
||||||
char.name = str(GameServerManager.players[i].name)
|
char.name = "PlayerPlaceholder_" + str(GameServerManager.players[i].name)
|
||||||
char.global_position = position
|
char.global_position = position
|
||||||
var my_random_number = RandomNumberGenerator.new().randf_range(0.0, 5.0)
|
var my_random_number = RandomNumberGenerator.new().randf_range(0.0, 5.0)
|
||||||
char.global_position = position
|
char.global_position = position
|
||||||
@ -26,7 +26,16 @@ func _ready() -> void:
|
|||||||
$MultiplayerSpawner.spawn(char)
|
$MultiplayerSpawner.spawn(char)
|
||||||
players.add_child(char)
|
players.add_child(char)
|
||||||
|
|
||||||
|
var bullet_amount: int = 0
|
||||||
|
func spawn_bullet(position):
|
||||||
|
print("spawning a bullet")
|
||||||
|
var node: Node3D = ResourceLoader.load("res://scenes/weapon/bullet.tscn").instantiate()
|
||||||
|
node.position = position.global_position
|
||||||
|
node.transform.basis = position.global_transform.basis
|
||||||
|
node.name = str(bullet_amount)
|
||||||
|
bullet_amount += 1
|
||||||
|
$BulletSpawner.spawn(node)
|
||||||
|
$Bullets.add_child(node)
|
||||||
# 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: float) -> void:
|
func _process(delta: float) -> void:
|
||||||
pass
|
pass
|
||||||
|
File diff suppressed because one or more lines are too long
11
scenes/maps/hit_counter.gd
Normal file
11
scenes/maps/hit_counter.gd
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
extends CSGBox3D
|
||||||
|
|
||||||
|
|
||||||
|
# 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: float) -> void:
|
||||||
|
pass
|
18
scenes/maps/hud.gd
Normal file
18
scenes/maps/hud.gd
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
extends Control
|
||||||
|
|
||||||
|
|
||||||
|
# Called when the node enters the scene tree for the first time.
|
||||||
|
func _ready() -> void:
|
||||||
|
pass # Replace with function body.
|
||||||
|
|
||||||
|
@onready var health_indicator: Label = $HealthIndicator
|
||||||
|
|
||||||
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
|
func _process(delta: float) -> void:
|
||||||
|
var root := get_tree().get_root()
|
||||||
|
var id := str(multiplayer.get_unique_id())
|
||||||
|
var placeholder: Node3D = root.find_child("*_" + id)
|
||||||
|
if placeholder:
|
||||||
|
health_indicator.text = placeholder.health
|
||||||
|
|
||||||
|
pass
|
@ -35,6 +35,14 @@ offset_right = 224.0
|
|||||||
offset_bottom = 220.0
|
offset_bottom = 220.0
|
||||||
text = "Join"
|
text = "Join"
|
||||||
|
|
||||||
|
[node name="TextEdit" type="TextEdit" parent="."]
|
||||||
|
layout_mode = 0
|
||||||
|
offset_left = 238.0
|
||||||
|
offset_top = 151.0
|
||||||
|
offset_right = 497.0
|
||||||
|
offset_bottom = 220.0
|
||||||
|
text = "192.168.0.28"
|
||||||
|
|
||||||
[connection signal="player_connected" from="." to="." method="_on_player_connected"]
|
[connection signal="player_connected" from="." to="." method="_on_player_connected"]
|
||||||
[connection signal="player_disconnected" from="." to="." method="_on_player_disconnected"]
|
[connection signal="player_disconnected" from="." to="." method="_on_player_disconnected"]
|
||||||
[connection signal="server_disconnected" from="." to="." method="_on_server_disconnected"]
|
[connection signal="server_disconnected" from="." to="." method="_on_server_disconnected"]
|
||||||
|
@ -10,7 +10,7 @@ signal server_disconnected
|
|||||||
const PORT = 7000
|
const PORT = 7000
|
||||||
const DEFAULT_SERVER_IP = "127.0.0.1" # IPv4 localhost
|
const DEFAULT_SERVER_IP = "127.0.0.1" # IPv4 localhost
|
||||||
const MAX_CONNECTIONS = 20
|
const MAX_CONNECTIONS = 20
|
||||||
|
@onready var address_input: TextEdit = $TextEdit
|
||||||
var players = {}
|
var players = {}
|
||||||
var my_random_number = RandomNumberGenerator.new().randf_range(-2.0, 2.0)
|
var my_random_number = RandomNumberGenerator.new().randf_range(-2.0, 2.0)
|
||||||
var player_info = {"name": str(my_random_number)}
|
var player_info = {"name": str(my_random_number)}
|
||||||
@ -25,8 +25,7 @@ func _ready() -> void:
|
|||||||
multiplayer.server_disconnected.connect(_on_server_disconnected)
|
multiplayer.server_disconnected.connect(_on_server_disconnected)
|
||||||
|
|
||||||
func join_game(address = ""):
|
func join_game(address = ""):
|
||||||
if address.is_empty():
|
address = address_input.text
|
||||||
address = DEFAULT_SERVER_IP
|
|
||||||
var peer = ENetMultiplayerPeer.new()
|
var peer = ENetMultiplayerPeer.new()
|
||||||
var error = peer.create_client(address, PORT)
|
var error = peer.create_client(address, PORT)
|
||||||
if error:
|
if error:
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
extends Node3D
|
extends Node3D
|
||||||
|
|
||||||
const SPEED = 715
|
const SPEED = 200 # 200
|
||||||
|
|
||||||
@onready var mesh = $RigidBody3D/MeshInstance3D
|
@onready var mesh = $RigidBody3D/MeshInstance3D
|
||||||
@onready var rigid_body_3d: RigidBody3D = $RigidBody3D
|
@onready var rigid_body_3d: RigidBody3D = $RigidBody3D
|
||||||
@ -14,12 +14,20 @@ 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 distance: float = time_per_frame * SPEED * 1.5
|
||||||
|
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
|
||||||
ray.target_position.z = SPEED / Engine.get_frames_per_second()
|
|
||||||
if ray.is_colliding():
|
if ray.is_colliding():
|
||||||
|
var collider = ray.get_collider()
|
||||||
|
if collider != null and collider.is_in_group("target"):
|
||||||
|
ray.get_collider().take_damage()
|
||||||
|
if collider != null and collider.is_in_group("body"):
|
||||||
|
print(collider)
|
||||||
|
ray.get_collider().hit()
|
||||||
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"):
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
[gd_scene load_steps=8 format=3 uid="uid://b0agqeg53tey5"]
|
[gd_scene load_steps=9 format=3 uid="uid://b0agqeg53tey5"]
|
||||||
|
|
||||||
[ext_resource type="Script" path="res://scenes/weapon/bullet.gd" id="1_th28m"]
|
[ext_resource type="Script" path="res://scenes/weapon/bullet.gd" id="1_th28m"]
|
||||||
|
|
||||||
@ -30,7 +30,16 @@ linear_accel_max = 6.67
|
|||||||
[sub_resource type="BoxMesh" id="BoxMesh_mfkmi"]
|
[sub_resource type="BoxMesh" id="BoxMesh_mfkmi"]
|
||||||
size = Vector3(0.05, 0.05, 0.05)
|
size = Vector3(0.05, 0.05, 0.05)
|
||||||
|
|
||||||
|
[sub_resource type="SceneReplicationConfig" id="SceneReplicationConfig_b8q4c"]
|
||||||
|
properties/0/path = NodePath(".:position")
|
||||||
|
properties/0/spawn = true
|
||||||
|
properties/0/replication_mode = 2
|
||||||
|
properties/1/path = NodePath(".:rotation")
|
||||||
|
properties/1/spawn = true
|
||||||
|
properties/1/replication_mode = 2
|
||||||
|
|
||||||
[node name="Bullet" type="Node3D"]
|
[node name="Bullet" type="Node3D"]
|
||||||
|
transform = Transform3D(20, 0, 0, 0, 20, 0, 0, 0, 20, 0, 0, 0)
|
||||||
script = ExtResource("1_th28m")
|
script = ExtResource("1_th28m")
|
||||||
|
|
||||||
[node name="RigidBody3D" type="RigidBody3D" parent="."]
|
[node name="RigidBody3D" type="RigidBody3D" parent="."]
|
||||||
@ -62,11 +71,14 @@ shape = SubResource("CylinderShape3D_l3sdq")
|
|||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0.18476)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0.18476)
|
||||||
material_override = SubResource("StandardMaterial3D_ynv38")
|
material_override = SubResource("StandardMaterial3D_ynv38")
|
||||||
emitting = false
|
emitting = false
|
||||||
amount = 10
|
amount = 100
|
||||||
lifetime = 6.29
|
lifetime = 6.29
|
||||||
one_shot = true
|
one_shot = true
|
||||||
explosiveness = 1.0
|
explosiveness = 1.0
|
||||||
process_material = SubResource("ParticleProcessMaterial_58cgi")
|
process_material = SubResource("ParticleProcessMaterial_58cgi")
|
||||||
draw_pass_1 = SubResource("BoxMesh_mfkmi")
|
draw_pass_1 = SubResource("BoxMesh_mfkmi")
|
||||||
|
|
||||||
|
[node name="MultiplayerSynchronizer" type="MultiplayerSynchronizer" parent="."]
|
||||||
|
replication_config = SubResource("SceneReplicationConfig_b8q4c")
|
||||||
|
|
||||||
[connection signal="timeout" from="RigidBody3D/Timer" to="." method="_on_timer_timeout"]
|
[connection signal="timeout" from="RigidBody3D/Timer" to="." method="_on_timer_timeout"]
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
extends Node3D
|
extends Node3D
|
||||||
|
|
||||||
const SPEED = 715
|
const SPEED = 10
|
||||||
|
|
||||||
@onready var mesh = $Object_10
|
@onready var mesh = $Object_10
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
extends MeshInstance3D
|
extends MeshInstance3D
|
||||||
|
|
||||||
|
var alpha = 1.0
|
||||||
func init(pos1, pos2):
|
func init(pos1, pos2):
|
||||||
var draw_mesh := ImmediateMesh.new()
|
var draw_mesh := ImmediateMesh.new()
|
||||||
mesh = draw_mesh
|
mesh = draw_mesh
|
||||||
@ -10,12 +11,15 @@ func init(pos1, pos2):
|
|||||||
|
|
||||||
# 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:
|
||||||
|
var dup_material = material_override.duplicate()
|
||||||
|
material_override = dup_material
|
||||||
pass # Replace with function body.
|
pass # Replace with function body.
|
||||||
|
|
||||||
|
|
||||||
# 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: float) -> void:
|
func _process(delta: float) -> void:
|
||||||
pass
|
alpha -= delta * 3.5
|
||||||
|
material_override.albedo_color.a = alpha
|
||||||
|
|
||||||
|
|
||||||
func _on_timer_timeout() -> void:
|
func _on_timer_timeout() -> void:
|
||||||
|
@ -3,9 +3,11 @@
|
|||||||
[ext_resource type="Script" path="res://scenes/weapon/misc/bullet_trail_generic.gd" id="1_k8eg1"]
|
[ext_resource type="Script" path="res://scenes/weapon/misc/bullet_trail_generic.gd" id="1_k8eg1"]
|
||||||
|
|
||||||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_ybqvs"]
|
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_ybqvs"]
|
||||||
albedo_color = Color(0.934388, 0.967243, 0.955863, 1)
|
transparency = 1
|
||||||
emission = Color(1, 1, 1, 1)
|
albedo_color = Color(0.917767, 0.596302, 0, 1)
|
||||||
emission_energy_multiplier = 2.7
|
emission_enabled = true
|
||||||
|
emission = Color(0.454139, 0.861507, 0, 1)
|
||||||
|
emission_energy_multiplier = 4.0
|
||||||
|
|
||||||
[node name="BulletTrailGeneric" type="MeshInstance3D"]
|
[node name="BulletTrailGeneric" type="MeshInstance3D"]
|
||||||
material_override = SubResource("StandardMaterial3D_ybqvs")
|
material_override = SubResource("StandardMaterial3D_ybqvs")
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
# ---------------------------------------------------------------------
|
# ---------------------------------------------------------------------
|
||||||
class_name PlayerInput extends CharacterBody3D
|
class_name PlayerInput extends CharacterBody3D
|
||||||
|
|
||||||
var health: int = 100
|
@export var health: int = 100
|
||||||
|
|
||||||
@export_category("PlayerInput")
|
@export_category("PlayerInput")
|
||||||
|
|
||||||
@ -38,6 +38,10 @@ func _ready() -> void:
|
|||||||
var err := _add_first_view_model()
|
var err := _add_first_view_model()
|
||||||
if err != OK:
|
if err != OK:
|
||||||
print("Error occured: " + str(err))
|
print("Error occured: " + str(err))
|
||||||
|
err = _add_legs_to_first_view()
|
||||||
|
if err != OK:
|
||||||
|
print("Error occured: " + str(err))
|
||||||
|
|
||||||
_enable_camera()
|
_enable_camera()
|
||||||
else:
|
else:
|
||||||
var err := _add_world_model()
|
var err := _add_world_model()
|
||||||
@ -64,6 +68,7 @@ var current_gun: String = "ak"
|
|||||||
@onready var gun_mount: Node3D = $FirstPersonCameraMount/GunMount
|
@onready var gun_mount: Node3D = $FirstPersonCameraMount/GunMount
|
||||||
@onready var gun_mount_anim: AnimationPlayer = $FirstPersonCameraMount/GunMount/AnimationPlayer
|
@onready var gun_mount_anim: AnimationPlayer = $FirstPersonCameraMount/GunMount/AnimationPlayer
|
||||||
var gun_with_hands: Node3D = null
|
var gun_with_hands: Node3D = null
|
||||||
|
|
||||||
# -- Add the first person view to pthe player
|
# -- Add the first person view to pthe player
|
||||||
func _add_first_view_model() -> Error :
|
func _add_first_view_model() -> Error :
|
||||||
# -- TODO: It should not be hardcoded
|
# -- TODO: It should not be hardcoded
|
||||||
@ -81,6 +86,30 @@ func _add_first_view_model() -> Error :
|
|||||||
gun_with_hands = node
|
gun_with_hands = node
|
||||||
gun_mount.add_child(node)
|
gun_mount.add_child(node)
|
||||||
return OK
|
return OK
|
||||||
|
|
||||||
|
|
||||||
|
var first_view_legs_anim: AnimationPlayer = null
|
||||||
|
# -- Add a world model to the player, that should be seen by other players
|
||||||
|
# -- on the server
|
||||||
|
func _add_legs_to_first_view() -> Error :
|
||||||
|
# -- TODO: It should not be hardcoded
|
||||||
|
var path := "res://scenes/characters/blue/dummy.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: Node3D = scene.instantiate()
|
||||||
|
var skeleton: Skeleton3D = node.find_child("Skeleton3D")
|
||||||
|
var bone := skeleton.find_bone("mixamorig_Spine")
|
||||||
|
if bone != -1:
|
||||||
|
skeleton.set_bone_pose_scale(bone, Vector3(0, 0, 0))
|
||||||
|
model_mount.add_child(node)
|
||||||
|
var animation_node: AnimationPlayer = node.find_child("AnimationPlayer")
|
||||||
|
if animation_node != null:
|
||||||
|
first_view_legs_anim = animation_node
|
||||||
|
return OK
|
||||||
|
|
||||||
|
|
||||||
func _enable_camera():
|
func _enable_camera():
|
||||||
first_view_camera.make_current()
|
first_view_camera.make_current()
|
||||||
@ -130,6 +159,14 @@ func _rotate_camera(sens_mod: float = 1.0) -> void:
|
|||||||
rotation.y -= look_dir.x * camera_sens * sens_mod
|
rotation.y -= look_dir.x * camera_sens * sens_mod
|
||||||
first_view_camera_mount.rotation.x = clamp(first_view_camera_mount.rotation.x - look_dir.y * camera_sens * sens_mod, -1.5, 1.5)
|
first_view_camera_mount.rotation.x = clamp(first_view_camera_mount.rotation.x - look_dir.y * camera_sens * sens_mod, -1.5, 1.5)
|
||||||
|
|
||||||
|
@onready var health_indicator = $FirstPersonCameraMount/HUD/HealthIndicator
|
||||||
|
@onready var fps_indicator = $FirstPersonCameraMount/HUD/FPS
|
||||||
|
func _process(delta: float) -> void:
|
||||||
|
health_indicator.text = str(health)
|
||||||
|
fps_indicator.text = str(Engine.get_frames_per_second())
|
||||||
|
if health == 0:
|
||||||
|
queue_free()
|
||||||
|
|
||||||
func _physics_process(delta: float) -> void:
|
func _physics_process(delta: float) -> void:
|
||||||
# Add the gravity.
|
# Add the gravity.
|
||||||
if not is_on_floor():
|
if not is_on_floor():
|
||||||
@ -148,11 +185,15 @@ func _physics_process(delta: float) -> void:
|
|||||||
var direction := (transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized()
|
var direction := (transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized()
|
||||||
if direction:
|
if direction:
|
||||||
gun_mount_anim.play("move")
|
gun_mount_anim.play("move")
|
||||||
|
if first_view_legs_anim != null:
|
||||||
|
first_view_legs_anim.play("Run Forward")
|
||||||
velocity.x = direction.x * SPEED
|
velocity.x = direction.x * SPEED
|
||||||
velocity.z = direction.z * SPEED
|
velocity.z = direction.z * SPEED
|
||||||
else:
|
else:
|
||||||
if gun_mount_anim.is_playing():
|
if gun_mount_anim.is_playing():
|
||||||
gun_mount_anim.stop()
|
gun_mount_anim.stop()
|
||||||
|
if first_view_legs_anim != null and first_view_legs_anim.is_playing():
|
||||||
|
first_view_legs_anim.stop()
|
||||||
velocity.x = move_toward(velocity.x, 0, SPEED)
|
velocity.x = move_toward(velocity.x, 0, SPEED)
|
||||||
velocity.z = move_toward(velocity.z, 0, SPEED)
|
velocity.z = move_toward(velocity.z, 0, SPEED)
|
||||||
|
|
||||||
@ -164,14 +205,28 @@ var bullet = load("res://scenes/weapon/bullet.tscn")
|
|||||||
@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
|
||||||
# --find the gun node and exec shoot
|
# --find the gun node and exec shoot
|
||||||
|
var cant_shoot: bool = false
|
||||||
func _shoot():
|
func _shoot():
|
||||||
if aim_ray.is_colliding():
|
if not cant_shoot:
|
||||||
var collider := aim_ray.get_collider()
|
_send_shot_to_server.rpc_id(1, aim_ray.global_position)
|
||||||
if collider != null and collider.is_in_group("target"):
|
if aim_ray.is_colliding():
|
||||||
aim_ray.get_collider().take_damage()
|
var collider := aim_ray.get_collider()
|
||||||
var root := get_tree().get_root()
|
if collider != null and collider.is_in_group("target"):
|
||||||
gun_with_hands.shoot()
|
aim_ray.get_collider().take_damage()
|
||||||
|
if collider != null and collider.is_in_group("body"):
|
||||||
|
collider.hit()
|
||||||
|
var root := get_tree().get_root()
|
||||||
|
gun_with_hands.shoot()
|
||||||
|
cant_shoot = true
|
||||||
|
await get_tree().create_timer(0.2).timeout
|
||||||
|
cant_shoot = false
|
||||||
|
|
||||||
|
@rpc("any_peer", "call_local", "unreliable_ordered")
|
||||||
|
func _send_shot_to_server(start_position):
|
||||||
|
# -- TODO: Should not be hardcoded
|
||||||
|
var world: Node3D = find_parent("ElTest")
|
||||||
|
world.spawn_bullet(bullet_starting_point)
|
||||||
|
|
||||||
func _get_camera_collision():
|
func _get_camera_collision():
|
||||||
var viewport = get_viewport().size
|
var viewport = get_viewport().size
|
||||||
var ray_origin = first_view_camera.project_ray_origin(viewport / 2)
|
var ray_origin = first_view_camera.project_ray_origin(viewport / 2)
|
||||||
@ -198,3 +253,8 @@ func _hit_scan_collision(collision_point):
|
|||||||
func _hit_scan_damage(Collider):
|
func _hit_scan_damage(Collider):
|
||||||
#if Collider.is_in_group("target") and Collider.has_method("take_damage"):
|
#if Collider.is_in_group("target") and Collider.has_method("take_damage"):
|
||||||
print("damaged")
|
print("damaged")
|
||||||
|
|
||||||
|
func take_damage(dam: int):
|
||||||
|
print("damage")
|
||||||
|
health -= dam
|
||||||
|
print(health)
|
||||||
|
Reference in New Issue
Block a user