Hey guys, I'm following a tutorial on youtube to develop a 2D platformer within Unity; I'm on the sixth video and we were learning how to fix the player's dying and respawning (By making the players death and respawn less instant by making a short delay an disabling player movement in order to make spawning much more apparent and efficient). But when the tutor was teaching how to setup and use a Coroutine to achieve delaying the "Level Manager" for a short time using a float to count down the time in order to transition the respawn. But before I attach the conflicting error, I'll link you all to the video and you should fastforward until about 14:20: https://www.youtube.com/watch?v=vwUahWrY9Jg&index=5&list=PLiyfvmtjWC_Up8XNvM3OSqgbJoMQgHkVz
and here's the snippet I'm having trouble with
public void RespawnPlayer()
{
StartCoroutine("RespawnPlayerCo");
}
public IEnumerator RespawnPlayerCo()
{
Instantiate(deathParticle, player.transform.position, player.transform.rotation);
player.enabled = false;
player.GetComponent().enabled = false;
Debug.Log("Player Respawn");
yield return new WaitForSeconds(respawnDelay);
player.transform.position = currentCheckPoint.transform.position;
Instantiate(respawnParticle, currentCheckPoint.transform.position, currentCheckPoint.transform.rotation);
}
I'm using Unity 5.1.2, C#, and Visual Studio 2015 on Windows 10 by the way, now the error that I can't seem to fix is this:
Severity Code Description Project File Line
Error `LevelManager.RespawnPlayerCo()': not all code paths return a value Solution Assets/Scripts/LevelManager.cs 33
I apologize if this is a bit messy, I've been up for more than 30 hours working on this project! Any help is much appreciated!
↧