- Home /
Question by
TuComix · Jun 17, 2015 at 07:21 PM ·
c#spriterendererdelayrespawnrenderer.enabled
2D project - player respawn delay problem
Hello there! I making some simple 2D side-scroller. Because I'm noob in programming, all my C# scripts for small systems are based on GamesPlusJames tutorials (youtube). Problem starts when I want to add some delay and make my player to dissappear.
Gamesplusjames had only one sprite renderer attach to player/character (etc) object, but my player is build with more sprites in more separate objects. The main problem is "character.renderer.enabled". Any ideas what I've should type instead?
public void RespawnCharacter()
{
StartCoroutine ("RespawnCharacterCo");
}
public IEnumerator RespawnCharacterCo()
{
Instantiate (deathParticle, character.transform.position, character.transform.rotation);
character.enabled = false;
character.renderer.enabled = false;
ScoreManager.AddPoints(-pointPenaltyOnDeath);
Debug.Log ("Character Respawn");
yield return new WaitForSeconds (respawnDelay);
character.transform.position = currentCheckpoint.transform.position;
character.enabled = true;
character.renderer.enabled = true;
Instantiate (respawnParticle, currentCheckpoint.transform.position, currentCheckpoint.transform.rotation);
}
Comment