Merge pull request 'Fix for respawn flashing the_adventures_of_teddy/public_issues#12' (#7) from respawn-tele-fix into main

Reviewed-on: #7
This commit is contained in:
Paul Black 2023-07-04 05:29:11 +00:00
commit dbd4148b9c
2 changed files with 18 additions and 12 deletions

View file

@ -86,18 +86,21 @@ func _physics_process(delta):
if is_multiplayer_authority(): if is_multiplayer_authority():
# This variable gets set my the death scene, so we know the player needs to be respawned # This variable gets set my the death scene, so we know the player needs to be respawned
if Global.playerPleaseRespawn == true: if Global.playerPleaseRespawn == true:
get_node(teddyCollider).disabled = false if not Global.respawnLocationChosen:
var ramMax = Global.spawnCoords_x.size() - 1 Global.respawnLocationChosen = true
var ramnum = RandomNumberGenerator.new().randi_range(0, ramMax) get_node(teddyCollider).disabled = false
print("ramnum: ", ramnum) var ramMax = Global.spawnCoords_x.size() - 1
print("ramMax: ", ramMax) var ramnum = RandomNumberGenerator.new().randi_range(0, ramMax)
position.x = Global.spawnCoords_x[ramnum] #Set player X print("ramnum: ", ramnum)
position.y = Global.spawnCoords_y[ramnum] #Set player Y print("ramMax: ", ramMax)
position.z = Global.spawnCoords_z[ramnum] #Set player Z position.x = Global.spawnCoords_x[ramnum] #Set player X
await get_tree().create_timer(0.5).timeout position.y = Global.spawnCoords_y[ramnum] #Set player Y
Global.reset_variables() position.z = Global.spawnCoords_z[ramnum] #Set player Z
ranRemovePlayer = false velocity = Vector3.ZERO
rpc("teddy_dead_nomore") 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 player falls off the map, kill them!
if velocity.y < Global.playerYDeath: if velocity.y < Global.playerYDeath:

View file

@ -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 playerDisable = false # Can be used to disable the player
var playerDeathHealth = 100 # Can be changed by death.gd var playerDeathHealth = 100 # Can be changed by death.gd
var kickAllPlayers = false # Can be set to true to kick all players in-game 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): func _process(delta):
spawn_locations() spawn_locations()
@ -74,6 +75,7 @@ func player_dead():
if deathShield <= 0: if deathShield <= 0:
deathShield = 50 deathShield = 50
if playerAlive: if playerAlive:
respawnLocationChosen = false
print("Player be deaddddd brooooooo") print("Player be deaddddd brooooooo")
var scene_trs =load("res://scenes/death.tscn") var scene_trs =load("res://scenes/death.tscn")
var scene=scene_trs.instantiate() var scene=scene_trs.instantiate()
@ -124,6 +126,7 @@ func reset_variables_hard():
playerDisable = false playerDisable = false
playerDeathHealth = 100 playerDeathHealth = 100
kickAllPlayers = false kickAllPlayers = false
respawnLocationChosen = false
func save_data(): func save_data():
SettingsFile.save_data() SettingsFile.save_data()