🐛 Fix network issues affecting flag and player movement

This commit is contained in:
Squinty 2024-04-17 16:07:24 +00:00
parent 327ea8f707
commit 55b1ac4fa1
9 changed files with 34 additions and 33 deletions

View file

@ -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)