Quantcast
Channel: Questions in topic: "renderer.enabled"
Viewing all articles
Browse latest Browse all 99

2D project - player respawn delay problem

$
0
0
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); }

Viewing all articles
Browse latest Browse all 99

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>