Spanker
1
So basically I’m re-spawning a player at a checkpoint and for a split second when it spawns it shows an image of the player somewhere else.
Its a bit hard to explain which is why I had no luck finding an answer for this. But it feels like it spawns somewhere else first and then quickly moves it to the checkpoint or somehow it shows the last frame before dying in a split second before going to checkpoint.
It could be from doing the transform.position too quickly but I even have a delay for the re-spawn and it happens no matter how many seconds I delay it.
This happens in every checkpoint. Here is the code I’m using. I’ve tried changing the order of the lines a bit and the camera related code but it doesn’t seem to solve it. When I run the game frame by frame this issue doesn’t happen and it also doesn’t happen 100% of the times but most of them.
It’s a coroutine called in a normal method.
public IEnumerator RespawnPlayerCo() {
Instantiate(deathParticle, player.transform.position, player.transform.rotation);
player.gameObject.SetActive(false);
cameraMain.isFollowing = false;
Debug.Log("Player Respawn");
yield return new WaitForSeconds(respawnDelay);
player.gameObject.SetActive(true);
cameraMain.isFollowing = true;
player.transform.position = currentCheckpoint.transform.position;
Instantiate(respawnParticle, currentCheckpoint.transform.position, currentCheckpoint.transform.rotation);
}
Gmotagi
2
@Spanker Have you tried putting the player.gameObject.SetActive after setting the position on line 10 ?
Maybe with a yield return new WaitForEndOfFrame() in between even?