mirror of
https://gitlab.com/open-fpsz/open-fpsz.git
synced 2026-01-19 19:44:46 +00:00
Merge branch 'fix/networking-issues' into 'develop'
🐛 Fix network issues affecting flag and player movement See merge request open-fpsz/open-fpsz!42
This commit is contained in:
commit
dbe9545590
|
|
@ -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 ExplosiveDamageComponent extends Area3D
|
||||
|
|
|
|||
|
|
@ -32,18 +32,16 @@ func _process(_delta):
|
|||
_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
|
||||
|
||||
@rpc("call_local")
|
||||
func _drop(throw_speed : float):
|
||||
func _release(inherited_velocity : Vector3, throw_speed : float):
|
||||
if _is_carrying():
|
||||
_carried_flag.drop()
|
||||
_carried_flag.rotation_degrees.x = 0.0
|
||||
_carried_flag.linear_velocity = attachment.global_basis.z * throw_speed
|
||||
_carried_flag.linear_velocity = inherited_velocity + (attachment.global_basis.z * throw_speed)
|
||||
_carried_flag = null
|
||||
|
||||
func _is_carrying() -> bool:
|
||||
|
|
@ -51,10 +49,10 @@ func _is_carrying() -> bool:
|
|||
|
||||
func _sensor_on_body_entered(collider):
|
||||
if collider is Flag:
|
||||
_grab.rpc(collider)
|
||||
_grab(collider)
|
||||
|
||||
func drop():
|
||||
_drop.rpc(0.0)
|
||||
_release(Vector3.ZERO, 0.0)
|
||||
|
||||
func throw():
|
||||
_drop.rpc(max_throw_speed)
|
||||
func throw(inherited_velocity : Vector3):
|
||||
_release(inherited_velocity, max_throw_speed)
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
[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"]
|
||||
[ext_resource type="PackedScene" uid="uid://d3l7fvbdg6m5g" path="res://entities/flag/assets/flag.glb" id="2_i78em"]
|
||||
|
||||
[sub_resource type="PhysicsMaterial" id="PhysicsMaterial_4ymrw"]
|
||||
bounce = 0.5
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ enum PlayerState { PLAYER_ALIVE, PLAYER_DEAD }
|
|||
@export_category("Parameters")
|
||||
@export var ground_speed : float = 48 / 3.6 # m/s
|
||||
@export var aerial_control_force : int = 400
|
||||
@export var jump_height : float = 2.0
|
||||
@export var max_floor_angle : float = 60
|
||||
|
||||
@export_group("Jetpack")
|
||||
|
|
@ -32,7 +33,7 @@ enum PlayerState { PLAYER_ALIVE, PLAYER_DEAD }
|
|||
|
||||
@export_group("State")
|
||||
@export var player_state = PlayerState.PLAYER_ALIVE
|
||||
@export var player_id = 1:
|
||||
@export var player_id : int = 1:
|
||||
set(id):
|
||||
player_id = id
|
||||
$PlayerInput.set_multiplayer_authority(id)
|
||||
|
|
@ -60,16 +61,16 @@ var _jumping = false
|
|||
|
||||
func _ready():
|
||||
energy_changed.connect(hud._on_energy_changed)
|
||||
health_component.health_changed.connect(hud._on_health_changed)
|
||||
health_component.health_changed.connect(iff._on_health_changed)
|
||||
health_component.health_changed.emit(health_component.health)
|
||||
health_component.health_zeroed.connect(_die)
|
||||
if _is_first_person():
|
||||
health_component.health_changed.connect(hud._on_health_changed)
|
||||
camera.current = true
|
||||
remove_child($ThirdPerson)
|
||||
else:
|
||||
remove_child($HUD)
|
||||
health_component.health_changed.connect(iff._on_health_changed)
|
||||
remove_child(hud)
|
||||
weapon.hide()
|
||||
health_component.health_changed.emit(health_component.health)
|
||||
health_component.health_zeroed.connect(die)
|
||||
input.fired_primary.connect(_fire_primary)
|
||||
input.jumped.connect(_jump)
|
||||
input.throwed_flag.connect(_throw_flag)
|
||||
|
|
@ -96,7 +97,7 @@ func _jump():
|
|||
_jumping = true
|
||||
|
||||
func _throw_flag():
|
||||
flag_carry_component.throw()
|
||||
flag_carry_component.throw(linear_velocity)
|
||||
|
||||
func is_on_floor() -> bool:
|
||||
if shape_cast.is_colliding():
|
||||
|
|
@ -176,8 +177,10 @@ func _physics_process(delta):
|
|||
|
||||
linear_velocity = lerp(linear_velocity, _direction * ground_speed, .1)
|
||||
|
||||
if _jumping:
|
||||
linear_velocity.y = sqrt(2 * abs((mass * gravity * delta).y) * 1)
|
||||
func _integrate_forces(_state):
|
||||
if is_on_floor() and _jumping:
|
||||
var v = sqrt(2 * g * jump_height)
|
||||
apply_central_impulse(Vector3(0, mass * v, 0))
|
||||
|
||||
_jumping = false
|
||||
|
||||
|
|
@ -202,7 +205,7 @@ func _update_third_person_animations():
|
|||
func _is_player_dead():
|
||||
return player_state == PlayerState.PLAYER_DEAD
|
||||
|
||||
func _die():
|
||||
func die():
|
||||
player_state = PlayerState.PLAYER_DEAD
|
||||
if _is_first_person():
|
||||
animation_player.stop()
|
||||
|
|
|
|||
|
|
@ -207,6 +207,7 @@ mass = 75.0
|
|||
physics_material_override = SubResource("PhysicsMaterial_clur0")
|
||||
continuous_cd = true
|
||||
script = ExtResource("1_mk68k")
|
||||
jump_height = 1.5
|
||||
|
||||
[node name="MeshInstance3D" type="MeshInstance3D" parent="."]
|
||||
visible = false
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ 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()
|
||||
|
|
@ -51,8 +51,6 @@ func _process(_delta):
|
|||
_throw_flag.rpc()
|
||||
jetting = Input.is_action_pressed("jump_and_jet")
|
||||
skiing = Input.is_action_pressed("ski")
|
||||
|
||||
func _physics_process(delta):
|
||||
_update_camera(delta)
|
||||
|
||||
@rpc("call_local")
|
||||
|
|
|
|||
|
|
@ -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 DummyTarget extends RigidBody3D
|
||||
|
|
|
|||
|
|
@ -31,7 +31,6 @@ func start_server(port, nickname):
|
|||
|
||||
load_map.call_deferred(MAP)
|
||||
|
||||
multiplayer.peer_connected.connect(add_player)
|
||||
multiplayer.peer_disconnected.connect(remove_player)
|
||||
|
||||
if DisplayServer.get_name() != \"headless\":
|
||||
|
|
@ -69,7 +68,9 @@ func add_player(peer_id : int, nickname : String):
|
|||
func remove_player(peer_id : int):
|
||||
var node_name = str(peer_id)
|
||||
if players.has_node(node_name):
|
||||
players.get_node(node_name).queue_free()
|
||||
var player : Player = players.get_node(node_name)
|
||||
player.die()
|
||||
player.queue_free()
|
||||
print(\"Peer `%s` disconnected\" % node_name)
|
||||
|
||||
@rpc(\"any_peer\")
|
||||
|
|
|
|||
|
|
@ -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/>.
|
||||
extends Node3D
|
||||
|
|
|
|||
Loading…
Reference in a new issue