This commit is contained in:
Paul Black 2023-02-28 12:30:49 -07:00
parent 6f674df510
commit 4e9dee7bb5

View file

@ -12,15 +12,18 @@ var gravity = ProjectSettings.get_setting("physics/3d/default_gravity")
@onready var camera := $CollisionShape3D/Neck/Camera3D
@onready var teddyAuthority = get_multiplayer_authority()
var selfTeddy
var teddyCollider
var teddyParent
var menuOpen = false
var globalscene
var ranRemovePlayer = false
func _ready():
name = str(teddyAuthority)
Global.playingGame = true
Global.selfTeddy = selfTeddy
selfTeddy = self.get_path()
teddyCollider = str(self.get_path()) + '/CollisionShape3D'
teddyParent = get_node(selfTeddy).get_parent()
Global.teddyAuthorityID = teddyAuthority
Global.playerName = $nameLabel
@ -62,6 +65,8 @@ func _physics_process(delta):
position.y = 10 #Set player Y
position.z = 0 #Set player Z
Global.reset_variables()
ranRemovePlayer = false
rpc("teddy_dead_nomore")
## If player falls off the map, kill them!
if velocity.y < Global.playerYDeath:
@ -69,6 +74,11 @@ func _physics_process(delta):
if Global.playerHealth <= 0:
Global.player_dead()
if ranRemovePlayer == false:
if Global.playerAlive == false:
ranRemovePlayer = true
#get_node(teddyCollider).disabled = true
rpc("remove_dead_teddy")
if Global.playerAlive:
# Handle Jump.
@ -131,3 +141,13 @@ func shoot_bullet():
b.velocity = -b.global_transform.basis.z * b.muzzle_velocity
$sound.stream = load("res://sounds/pistol_shoot.wav")
$sound.play()
@rpc("any_peer")
func remove_dead_teddy():
get_node(selfTeddy).visible = false
get_node(teddyCollider).disabled = true
@rpc("any_peer")
func teddy_dead_nomore():
get_node(selfTeddy).visible = true
get_node(teddyCollider).disabled = false