mirror of
https://gitlab.com/open-fpsz/open-fpsz.git
synced 2026-01-20 03:54:47 +00:00
Merge branch 'feat/flag' into 'develop'
Flag entitty implemented See merge request open-fpsz/open-fpsz!37
This commit is contained in:
commit
94b7ee0a53
|
|
@ -4,6 +4,6 @@
|
|||
|
||||
[node name="ExplosiveDamage" type="Area3D"]
|
||||
collision_layer = 0
|
||||
collision_mask = 5
|
||||
collision_mask = 13
|
||||
monitorable = false
|
||||
script = ExtResource("1_2uehk")
|
||||
|
|
|
|||
35
components/flag_carry_component.gd
Normal file
35
components/flag_carry_component.gd
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
class_name FlagCarryComponent extends Node
|
||||
|
||||
@export var throw_velocity : float = 10.0
|
||||
@export var attachment : Node3D
|
||||
@export var sensor : Area3D
|
||||
|
||||
var _carried_flag : Flag
|
||||
|
||||
func _ready():
|
||||
sensor.body_entered.connect(_sensor_on_body_entered)
|
||||
|
||||
func _process(_delta):
|
||||
if _is_carrying():
|
||||
_carried_flag.global_position = attachment.global_position
|
||||
_carried_flag.global_rotation = attachment.global_rotation
|
||||
|
||||
@rpc("call_local")
|
||||
func _grab(flag : Flag):
|
||||
if not _is_carrying():
|
||||
flag.grab()
|
||||
_carried_flag = flag
|
||||
|
||||
func throw():
|
||||
if _is_carrying():
|
||||
_carried_flag.drop()
|
||||
_carried_flag.linear_velocity = attachment.global_basis.z * throw_velocity
|
||||
_carried_flag.rotation_degrees.x = 0.0
|
||||
_carried_flag = null
|
||||
|
||||
func _is_carrying() -> bool:
|
||||
return _carried_flag != null
|
||||
|
||||
func _sensor_on_body_entered(collider):
|
||||
if collider is Flag:
|
||||
_grab.rpc(collider)
|
||||
6
components/flag_carry_component.tscn
Normal file
6
components/flag_carry_component.tscn
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
[gd_scene load_steps=2 format=3 uid="uid://2t8ql8pkxv6c"]
|
||||
|
||||
[ext_resource type="Script" path="res://components/flag_carry_component.gd" id="1_b6ee8"]
|
||||
|
||||
[node name="FlagCarryComponent" type="Node"]
|
||||
script = ExtResource("1_b6ee8")
|
||||
BIN
entities/flag/assets/flag.glb
Normal file
BIN
entities/flag/assets/flag.glb
Normal file
Binary file not shown.
5
entities/flag/assets/flag.tscn
Normal file
5
entities/flag/assets/flag.tscn
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
[gd_scene load_steps=2 format=3 uid="uid://b8xj25dhhbagw"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://bftyiy6r0xaa3" path="res://entities/flag/assets/flag.glb" id="1_pd02q"]
|
||||
|
||||
[node name="flag2" instance=ExtResource("1_pd02q")]
|
||||
17
entities/flag/flag.gd
Normal file
17
entities/flag/flag.gd
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
class_name Flag extends Node3D
|
||||
|
||||
enum FlagState { FLAG_STATE_ON_STAND, FLAG_STATE_DROPPED, FLAG_STATE_TAKEN }
|
||||
|
||||
@export var flag_state : FlagState = FlagState.FLAG_STATE_ON_STAND
|
||||
|
||||
func can_be_grabbed():
|
||||
return flag_state != FlagState.FLAG_STATE_TAKEN
|
||||
|
||||
func grab():
|
||||
if flag_state != FlagState.FLAG_STATE_TAKEN:
|
||||
flag_state = FlagState.FLAG_STATE_TAKEN
|
||||
|
||||
func drop():
|
||||
if flag_state == FlagState.FLAG_STATE_TAKEN:
|
||||
flag_state = FlagState.FLAG_STATE_DROPPED
|
||||
|
||||
42
entities/flag/flag.tscn
Normal file
42
entities/flag/flag.tscn
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
[gd_scene load_steps=6 format=3 uid="uid://c88l3h0ph00c7"]
|
||||
|
||||
[ext_resource type="Script" path="res://entities/flag/flag.gd" id="1_y7d3d"]
|
||||
[ext_resource type="PackedScene" uid="uid://bftyiy6r0xaa3" path="res://entities/flag/assets/flag.glb" id="2_i78em"]
|
||||
|
||||
[sub_resource type="PhysicsMaterial" id="PhysicsMaterial_4ymrw"]
|
||||
bounce = 0.5
|
||||
|
||||
[sub_resource type="BoxShape3D" id="BoxShape3D_fkf1k"]
|
||||
size = Vector3(0.5, 2, 0.1)
|
||||
|
||||
[sub_resource type="SceneReplicationConfig" id="SceneReplicationConfig_lpijf"]
|
||||
properties/0/path = NodePath(".:position")
|
||||
properties/0/spawn = true
|
||||
properties/0/replication_mode = 1
|
||||
properties/1/path = NodePath(".:linear_velocity")
|
||||
properties/1/spawn = true
|
||||
properties/1/replication_mode = 1
|
||||
properties/2/path = NodePath(".:flag_state")
|
||||
properties/2/spawn = true
|
||||
properties/2/replication_mode = 2
|
||||
|
||||
[node name="Flag" type="RigidBody3D"]
|
||||
collision_layer = 8
|
||||
collision_mask = 2147483656
|
||||
axis_lock_angular_x = true
|
||||
axis_lock_angular_y = true
|
||||
axis_lock_angular_z = true
|
||||
mass = 40.0
|
||||
physics_material_override = SubResource("PhysicsMaterial_4ymrw")
|
||||
continuous_cd = true
|
||||
script = ExtResource("1_y7d3d")
|
||||
|
||||
[node name="Mesh" parent="." instance=ExtResource("2_i78em")]
|
||||
transform = Transform3D(0.33, 0, 0, 0, 0.421029, 0, 0, 0, 0.33, 0, 0.0744106, 0)
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0)
|
||||
shape = SubResource("BoxShape3D_fkf1k")
|
||||
|
||||
[node name="MultiplayerSynchronizer" type="MultiplayerSynchronizer" parent="."]
|
||||
replication_config = SubResource("SceneReplicationConfig_lpijf")
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,15 +1,15 @@
|
|||
# This file is part of open-fpsz.
|
||||
#
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
class_name Player extends RigidBody3D
|
||||
|
|
@ -41,12 +41,14 @@ enum PlayerState { PLAYER_ALIVE, PLAYER_DEAD }
|
|||
@onready var camera = $SpringArm3D/Camera3D
|
||||
@onready var hud = $HUD
|
||||
@onready var iff = $ThirdPerson/IFF
|
||||
@onready var shape_cast = $ShapeCast3D
|
||||
@onready var shape_cast : ShapeCast3D = $ShapeCast3D
|
||||
@onready var weapon = $SpringArm3D/Inventory/SpaceGun
|
||||
@onready var animation_player : AnimationPlayer = $AnimationPlayer
|
||||
@onready var health_component = $HealthComponent
|
||||
@onready var flag_carry_component = $FlagCarryComponent
|
||||
@onready var spring_arm_height = $SpringArm3D.position.y
|
||||
@onready var _original_weapon_transform : Transform3D = weapon.transform
|
||||
@onready var flag_carry_attachment = $SpringArm3D/FlagCarryAttachment
|
||||
|
||||
signal died(player)
|
||||
signal energy_changed(energy)
|
||||
|
|
@ -63,12 +65,14 @@ func _ready():
|
|||
health_component.health_zeroed.connect(_die)
|
||||
if _is_first_person():
|
||||
camera.current = true
|
||||
flag_carry_attachment.hide()
|
||||
remove_child($ThirdPerson)
|
||||
else:
|
||||
remove_child($HUD)
|
||||
weapon.hide()
|
||||
input.fired_primary.connect(_fire_primary)
|
||||
input.jumped.connect(_jump)
|
||||
input.throwed_flag.connect(_throw_flag)
|
||||
|
||||
func _is_first_person():
|
||||
return player_id == multiplayer.get_unique_id()
|
||||
|
|
@ -91,13 +95,21 @@ func _jump():
|
|||
return
|
||||
_jumping = true
|
||||
|
||||
func _throw_flag():
|
||||
flag_carry_component.throw()
|
||||
|
||||
func is_on_floor() -> bool:
|
||||
return shape_cast.is_colliding()
|
||||
if shape_cast.is_colliding():
|
||||
for i in shape_cast.get_collision_count():
|
||||
var collider = shape_cast.get_collider(i)
|
||||
if collider is Terrain3D:
|
||||
return true
|
||||
return false
|
||||
|
||||
func _is_skiing() -> bool:
|
||||
return input.skiing
|
||||
|
||||
func _handle_aerial_control(delta, direction):
|
||||
func _handle_aerial_control(direction):
|
||||
if not input.jetting and not is_on_floor():
|
||||
apply_force(direction * aerial_control_force)
|
||||
|
||||
|
|
@ -142,7 +154,7 @@ func _physics_process(delta):
|
|||
# adjust direction based on spring arm rotation
|
||||
_direction = _direction.rotated(Vector3.UP, $SpringArm3D.rotation.y)
|
||||
|
||||
_handle_aerial_control(delta, _direction)
|
||||
_handle_aerial_control(_direction)
|
||||
_handle_jetpack(delta, _direction)
|
||||
|
||||
# handle ski
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=20 format=3 uid="uid://cbhx1xme0sb7k"]
|
||||
[gd_scene load_steps=21 format=3 uid="uid://cbhx1xme0sb7k"]
|
||||
|
||||
[ext_resource type="Script" path="res://entities/player/player.gd" id="1_mk68k"]
|
||||
[ext_resource type="Shape3D" uid="uid://dkwljsgaflf31" path="res://entities/player/collision_shape.res" id="2_8rtw3"]
|
||||
|
|
@ -9,6 +9,7 @@
|
|||
[ext_resource type="PackedScene" uid="uid://bof3mg7wgxrmn" path="res://components/health_component.tscn" id="5_t6i6e"]
|
||||
[ext_resource type="Script" path="res://entities/player/player_input.gd" id="6_ymcrr"]
|
||||
[ext_resource type="PackedScene" uid="uid://dsysi2rd3bu76" path="res://interfaces/hud/iff.tscn" id="7_8hc80"]
|
||||
[ext_resource type="PackedScene" uid="uid://2t8ql8pkxv6c" path="res://components/flag_carry_component.tscn" id="7_e7s1a"]
|
||||
|
||||
[sub_resource type="PhysicsMaterial" id="PhysicsMaterial_clur0"]
|
||||
resource_local_to_scene = true
|
||||
|
|
@ -195,6 +196,7 @@ properties/3/spawn = false
|
|||
properties/3/replication_mode = 2
|
||||
|
||||
[node name="Player" type="RigidBody3D"]
|
||||
collision_mask = 2147483649
|
||||
axis_lock_angular_x = true
|
||||
axis_lock_angular_y = true
|
||||
axis_lock_angular_z = true
|
||||
|
|
@ -214,8 +216,17 @@ shape = ExtResource("2_8rtw3")
|
|||
transform = Transform3D(1.05, 0, 0, 0, 1.05, 0, 0, 0, 1.05, 0, 0, 0)
|
||||
shape = ExtResource("2_8rtw3")
|
||||
target_position = Vector3(0, 0, 0)
|
||||
collision_mask = 2147483656
|
||||
collide_with_areas = true
|
||||
|
||||
[node name="Sensor" type="Area3D" parent="."]
|
||||
collision_layer = 0
|
||||
collision_mask = 8
|
||||
monitorable = false
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="Sensor"]
|
||||
shape = ExtResource("2_8rtw3")
|
||||
|
||||
[node name="HUD" parent="." instance=ExtResource("3_ccety")]
|
||||
|
||||
[node name="SpringArm3D" type="SpringArm3D" parent="."]
|
||||
|
|
@ -236,8 +247,29 @@ PROJECTILE = ExtResource("5_lvaut")
|
|||
[node name="SpineIKTarget" type="Node3D" parent="SpringArm3D"]
|
||||
transform = Transform3D(-1, 0, -8.74228e-08, 0, 1, 0, 8.74228e-08, 0, -1, 0, 0, 0)
|
||||
|
||||
[node name="FlagCarryAttachment" type="Node3D" parent="SpringArm3D"]
|
||||
transform = Transform3D(-1, 0, -8.74228e-08, 0, 1, 0, 8.74228e-08, 0, -1, 0, -0.620994, -0.287925)
|
||||
|
||||
[node name="HealthComponent" parent="." instance=ExtResource("5_t6i6e")]
|
||||
|
||||
[node name="FlagCarryComponent" parent="." node_paths=PackedStringArray("attachment", "sensor") instance=ExtResource("7_e7s1a")]
|
||||
throw_velocity = 20.0
|
||||
attachment = NodePath("../SpringArm3D/FlagCarryAttachment")
|
||||
sensor = NodePath("../Sensor")
|
||||
|
||||
[node name="ThirdPerson" type="Node3D" parent="."]
|
||||
|
||||
[node name="PlayerMesh" parent="ThirdPerson" node_paths=PackedStringArray("spine_ik_target_attachment") instance=ExtResource("2_beyex")]
|
||||
transform = Transform3D(-1, 0, -8.74228e-08, 0, 1, 0, 8.74228e-08, 0, -1, 0, 0, 0)
|
||||
spine_ik_target_attachment = NodePath("../../SpringArm3D/SpineIKTarget")
|
||||
|
||||
[node name="IFFAttachment" type="Node3D" parent="ThirdPerson"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.27457, 0)
|
||||
|
||||
[node name="IFF" parent="ThirdPerson" node_paths=PackedStringArray("attach_point", "player") instance=ExtResource("7_8hc80")]
|
||||
attach_point = NodePath("../IFFAttachment")
|
||||
player = NodePath("../..")
|
||||
|
||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
||||
libraries = {
|
||||
"": SubResource("AnimationLibrary_hg307")
|
||||
|
|
@ -252,16 +284,3 @@ replication_config = SubResource("SceneReplicationConfig_rqdp6")
|
|||
root_path = NodePath(".")
|
||||
replication_config = SubResource("SceneReplicationConfig_5j4ew")
|
||||
script = ExtResource("6_ymcrr")
|
||||
|
||||
[node name="ThirdPerson" type="Node3D" parent="."]
|
||||
|
||||
[node name="PlayerMesh" parent="ThirdPerson" node_paths=PackedStringArray("spine_ik_target_attachment") instance=ExtResource("2_beyex")]
|
||||
transform = Transform3D(-1, 0, -8.74228e-08, 0, 1, 0, 8.74228e-08, 0, -1, 0, 0, 0)
|
||||
spine_ik_target_attachment = NodePath("../../SpringArm3D/SpineIKTarget")
|
||||
|
||||
[node name="IFFAttachment" type="Node3D" parent="ThirdPerson"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.27457, 0)
|
||||
|
||||
[node name="IFF" parent="ThirdPerson" node_paths=PackedStringArray("attach_point", "player") instance=ExtResource("7_8hc80")]
|
||||
attach_point = NodePath("../IFFAttachment")
|
||||
player = NodePath("../..")
|
||||
|
|
|
|||
|
|
@ -1,15 +1,15 @@
|
|||
# This file is part of open-fpsz.
|
||||
#
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
class_name PlayerInput extends MultiplayerSynchronizer
|
||||
|
|
@ -22,6 +22,7 @@ class_name PlayerInput extends MultiplayerSynchronizer
|
|||
|
||||
signal jumped
|
||||
signal fired_primary
|
||||
signal throwed_flag
|
||||
|
||||
var _mouse_position: Vector2
|
||||
|
||||
|
|
@ -40,12 +41,14 @@ func _unhandled_input(event: InputEvent) -> void:
|
|||
# retrieve mouse position relative to last frame
|
||||
_mouse_position = event.relative * MOUSE_SENSITIVITY
|
||||
|
||||
func _process(delta):
|
||||
func _process(_delta):
|
||||
direction = Input.get_vector("left", "right", "forward", "backward")
|
||||
if Input.is_action_just_pressed("jump_and_jet"):
|
||||
_jump.rpc()
|
||||
if Input.is_action_just_pressed("fire_primary"):
|
||||
_fire_primary.rpc()
|
||||
if Input.is_action_just_pressed("throw_flag"):
|
||||
_throw_flag.rpc()
|
||||
jetting = Input.is_action_pressed("jump_and_jet")
|
||||
skiing = Input.is_action_pressed("ski")
|
||||
|
||||
|
|
@ -60,6 +63,10 @@ func _jump():
|
|||
func _fire_primary():
|
||||
fired_primary.emit()
|
||||
|
||||
@rpc("call_local")
|
||||
func _throw_flag():
|
||||
throwed_flag.emit()
|
||||
|
||||
func _update_camera(delta):
|
||||
# clamp vertical rotation (head motion)
|
||||
camera_rotation.y -= _mouse_position.y * delta
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@
|
|||
radius = 0.3
|
||||
|
||||
[node name="TargetDummy" type="RigidBody3D"]
|
||||
collision_layer = 2147483649
|
||||
collision_mask = 2147483649
|
||||
axis_lock_angular_x = true
|
||||
axis_lock_angular_y = true
|
||||
axis_lock_angular_z = true
|
||||
|
|
@ -57,7 +59,6 @@ bones/27/scale = Vector3(1, 1, 1)
|
|||
bones/28/rotation = Quaternion(-0.144176, 0.0367847, -0.00247504, 0.988865)
|
||||
bones/28/scale = Vector3(1, 1, 1)
|
||||
bones/30/rotation = Quaternion(-0.0630717, 0.16283, -0.0971492, 0.979832)
|
||||
bones/30/scale = Vector3(1, 1, 1)
|
||||
bones/31/rotation = Quaternion(0.0237032, 0.0123211, -0.0433656, 0.998702)
|
||||
bones/31/scale = Vector3(1, 1, 1)
|
||||
bones/32/rotation = Quaternion(0.243143, 0.523041, 0.164477, 0.800161)
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
[ext_resource type="PackedScene" uid="uid://boviiugcnfyrj" path="res://modes/demo.tscn" id="1_50a80"]
|
||||
[ext_resource type="PackedScene" uid="uid://bjctlqvs33nqy" path="res://interfaces/menus/boot/boot.tscn" id="1_acy5o"]
|
||||
[ext_resource type="PackedScene" uid="uid://c7ae4jw5d8mue" path="res://modes/multiplayer.tscn" id="2_g8xeb"]
|
||||
[ext_resource type="PackedScene" uid="uid://bvwxfgygm2xb8" path="res://modes/multiplayer.tscn" id="2_g8xeb"]
|
||||
|
||||
[sub_resource type="GDScript" id="GDScript_e61dq"]
|
||||
script/source = "class_name Game extends Node3D
|
||||
|
|
@ -20,20 +20,20 @@ func _ready():
|
|||
|
||||
func _start_demo():
|
||||
if mode: mode.queue_free()
|
||||
mode = SINGLEPLAYER.instantiate() # demo scene
|
||||
mode = SINGLEPLAYER.instantiate()
|
||||
add_child(mode)
|
||||
$BootMenu.hide()
|
||||
|
||||
func _start_server(port):
|
||||
if mode: mode.queue_free()
|
||||
mode = MULTIPLAYER.instantiate() # server scene
|
||||
mode = MULTIPLAYER.instantiate()
|
||||
add_child(mode)
|
||||
mode.start_server(port)
|
||||
$BootMenu.hide()
|
||||
|
||||
func _join_server(host, port):
|
||||
if mode: mode.queue_free()
|
||||
mode = MULTIPLAYER.instantiate() # client scene
|
||||
mode = MULTIPLAYER.instantiate()
|
||||
add_child(mode)
|
||||
mode.connected_to_server.connect($BootMenu/Multiplayer._on_connected_to_server)
|
||||
mode.connection_failed.connect($BootMenu/Multiplayer._on_connection_failed)
|
||||
|
|
|
|||
|
|
@ -45,3 +45,5 @@ environment = SubResource("Environment_6whfw")
|
|||
storage = ExtResource("1_a88qe")
|
||||
material = ExtResource("2_o2y3d")
|
||||
texture_list = ExtResource("3_1cww7")
|
||||
collision_layer = 2147483648
|
||||
collision_mask = 2147483648
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
[gd_scene load_steps=6 format=3 uid="uid://boviiugcnfyrj"]
|
||||
[gd_scene load_steps=7 format=3 uid="uid://boviiugcnfyrj"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://cbhx1xme0sb7k" path="res://entities/player/player.tscn" id="2_6wbjq"]
|
||||
[ext_resource type="PackedScene" uid="uid://chbno00ugl6te" path="res://maps/genesis/genesis.tscn" id="2_lsep7"]
|
||||
[ext_resource type="PackedScene" uid="uid://dpnu1lvfncx6q" path="res://entities/target_dummy/target_dummy.tscn" id="3_fkq5v"]
|
||||
[ext_resource type="PackedScene" uid="uid://c88l3h0ph00c7" path="res://entities/flag/flag.tscn" id="4_1j2pw"]
|
||||
|
||||
[sub_resource type="GDScript" id="GDScript_iv0l6"]
|
||||
script/source = "extends Node
|
||||
|
|
@ -35,3 +36,6 @@ physics_material_override = SubResource("PhysicsMaterial_c5jqv")
|
|||
|
||||
[node name="TargetDummy" parent="." instance=ExtResource("3_fkq5v")]
|
||||
transform = Transform3D(-0.995746, 0, -0.0921446, 0, 1, 0, 0.0921446, 0, -0.995746, 15.757, 95.1745, 0)
|
||||
|
||||
[node name="Flag" parent="." instance=ExtResource("4_1j2pw")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 5.43107, 92.1318, -3.324)
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
[gd_scene load_steps=4 format=3 uid="uid://bvwxfgygm2xb8"]
|
||||
[gd_scene load_steps=5 format=3 uid="uid://bvwxfgygm2xb8"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://chbno00ugl6te" path="res://maps/genesis/genesis.tscn" id="1_nulvv"]
|
||||
[ext_resource type="PackedScene" uid="uid://cbhx1xme0sb7k" path="res://entities/player/player.tscn" id="2_og1vb"]
|
||||
[ext_resource type="PackedScene" uid="uid://c88l3h0ph00c7" path="res://entities/flag/flag.tscn" id="3_h0rie"]
|
||||
|
||||
[sub_resource type="GDScript" id="GDScript_1qrbp"]
|
||||
script/source = "class_name Multiplayer extends Node
|
||||
|
|
@ -9,10 +10,12 @@ script/source = "class_name Multiplayer extends Node
|
|||
@export_category(\"Parameters\")
|
||||
@export var MAP : PackedScene
|
||||
@export var PLAYER : PackedScene
|
||||
@export var FLAG : PackedScene
|
||||
@export var MAX_CLIENTS : int = 24
|
||||
|
||||
@onready var map = $Map
|
||||
@onready var players = $Players
|
||||
@onready var objectives = $Objectives
|
||||
|
||||
signal connected_to_server
|
||||
signal connection_failed
|
||||
|
|
@ -37,6 +40,8 @@ func start_server(port):
|
|||
if DisplayServer.get_name() != \"headless\":
|
||||
add_player(1)
|
||||
|
||||
add_flag()
|
||||
|
||||
func join_server(host, port):
|
||||
var peer = ENetMultiplayerPeer.new()
|
||||
peer.create_client(host, port)
|
||||
|
|
@ -68,6 +73,11 @@ func remove_player(peer_id : int):
|
|||
players.get_node(node_name).queue_free()
|
||||
print(\"Peer `%s` disconnected\" % node_name)
|
||||
|
||||
func add_flag():
|
||||
var flag : Flag = FLAG.instantiate()
|
||||
flag.position = Vector3(5.0, 100.0, 0.0)
|
||||
objectives.add_child(flag)
|
||||
|
||||
func _exit_tree():
|
||||
if multiplayer.is_server():
|
||||
multiplayer.peer_connected.disconnect(add_player)
|
||||
|
|
@ -78,6 +88,7 @@ func _exit_tree():
|
|||
script = SubResource("GDScript_1qrbp")
|
||||
MAP = ExtResource("1_nulvv")
|
||||
PLAYER = ExtResource("2_og1vb")
|
||||
FLAG = ExtResource("3_h0rie")
|
||||
|
||||
[node name="Map" type="Node" parent="."]
|
||||
|
||||
|
|
@ -91,3 +102,9 @@ spawn_limit = 1
|
|||
[node name="PlayersSpawner" type="MultiplayerSpawner" parent="."]
|
||||
_spawnable_scenes = PackedStringArray("res://entities/player/player.tscn")
|
||||
spawn_path = NodePath("../Players")
|
||||
|
||||
[node name="Objectives" type="Node" parent="."]
|
||||
|
||||
[node name="ObjectivesSpawner" type="MultiplayerSpawner" parent="."]
|
||||
_spawnable_scenes = PackedStringArray("res://entities/flag/flag.tscn")
|
||||
spawn_path = NodePath("../Objectives")
|
||||
|
|
|
|||
|
|
@ -75,6 +75,11 @@ fire_primary={
|
|||
"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":1,"canceled":false,"pressed":false,"double_click":false,"script":null)
|
||||
]
|
||||
}
|
||||
throw_flag={
|
||||
"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":70,"key_label":0,"unicode":102,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
toggle_mouse_capture={
|
||||
"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":4194332,"key_label":0,"unicode":0,"echo":false,"script":null)
|
||||
|
|
@ -84,6 +89,8 @@ toggle_mouse_capture={
|
|||
[layer_names]
|
||||
|
||||
3d_physics/layer_3="Damage"
|
||||
3d_physics/layer_4="Objective"
|
||||
3d_physics/layer_32="Terrain"
|
||||
|
||||
[physics]
|
||||
|
||||
|
|
|
|||
|
|
@ -45,4 +45,5 @@ shape = SubResource("SphereShape3D_umtte")
|
|||
target_position = Vector3(0, 0, 0)
|
||||
margin = 0.1
|
||||
max_results = 1
|
||||
collision_mask = 2147483649
|
||||
debug_shape_custom_color = Color(1, 0, 0, 1)
|
||||
|
|
|
|||
Loading…
Reference in a new issue