Fix for respawn flashing https://git.techwizz-emu.com/the_adventures_of_teddy/public_issues/issues/12 #7
2 changed files with 18 additions and 12 deletions
|
@ -86,18 +86,21 @@ func _physics_process(delta):
|
|||
if is_multiplayer_authority():
|
||||
# This variable gets set my the death scene, so we know the player needs to be respawned
|
||||
if Global.playerPleaseRespawn == true:
|
||||
get_node(teddyCollider).disabled = false
|
||||
var ramMax = Global.spawnCoords_x.size() - 1
|
||||
var ramnum = RandomNumberGenerator.new().randi_range(0, ramMax)
|
||||
print("ramnum: ", ramnum)
|
||||
print("ramMax: ", ramMax)
|
||||
position.x = Global.spawnCoords_x[ramnum] #Set player X
|
||||
position.y = Global.spawnCoords_y[ramnum] #Set player Y
|
||||
position.z = Global.spawnCoords_z[ramnum] #Set player Z
|
||||
await get_tree().create_timer(0.5).timeout
|
||||
Global.reset_variables()
|
||||
ranRemovePlayer = false
|
||||
rpc("teddy_dead_nomore")
|
||||
if not Global.respawnLocationChosen:
|
||||
Global.respawnLocationChosen = true
|
||||
get_node(teddyCollider).disabled = false
|
||||
var ramMax = Global.spawnCoords_x.size() - 1
|
||||
var ramnum = RandomNumberGenerator.new().randi_range(0, ramMax)
|
||||
print("ramnum: ", ramnum)
|
||||
print("ramMax: ", ramMax)
|
||||
position.x = Global.spawnCoords_x[ramnum] #Set player X
|
||||
position.y = Global.spawnCoords_y[ramnum] #Set player Y
|
||||
position.z = Global.spawnCoords_z[ramnum] #Set player Z
|
||||
velocity = Vector3.ZERO
|
||||
await get_tree().create_timer(0.5).timeout
|
||||
Global.reset_variables()
|
||||
ranRemovePlayer = false
|
||||
rpc("teddy_dead_nomore")
|
||||
|
||||
## If player falls off the map, kill them!
|
||||
if velocity.y < Global.playerYDeath:
|
||||
|
|
|
@ -53,6 +53,7 @@ var tutorialTimerCompleted = false # Used for after the timer goes off in the tu
|
|||
var playerDisable = false # Can be used to disable the player
|
||||
var playerDeathHealth = 100 # Can be changed by death.gd
|
||||
var kickAllPlayers = false # Can be set to true to kick all players in-game
|
||||
var respawnLocationChosen = false # When set to false, the game will be allowed to select a spawnpoint for the player
|
||||
|
||||
func _process(delta):
|
||||
spawn_locations()
|
||||
|
@ -74,6 +75,7 @@ func player_dead():
|
|||
if deathShield <= 0:
|
||||
deathShield = 50
|
||||
if playerAlive:
|
||||
respawnLocationChosen = false
|
||||
print("Player be deaddddd brooooooo")
|
||||
var scene_trs =load("res://scenes/death.tscn")
|
||||
var scene=scene_trs.instantiate()
|
||||
|
@ -124,6 +126,7 @@ func reset_variables_hard():
|
|||
playerDisable = false
|
||||
playerDeathHealth = 100
|
||||
kickAllPlayers = false
|
||||
respawnLocationChosen = false
|
||||
|
||||
func save_data():
|
||||
SettingsFile.save_data()
|
||||
|
|
Loading…
Reference in a new issue