Quantcast
Channel: Latest Questions on Unity Answers
Viewing all articles
Browse latest Browse all 171066

How to make a variable it's original value?

$
0
0
I made a script that counts the number of times and object collides with it and when it reaches 0, the object is destroyed and later teleported to another location. Here is the script: var lives = 5; var spawnPoint : Transform; var seconds = 2.0; function OnTriggerEnter(){ (lives) = (lives) - 1; if((lives) == 0){ Invoke("LiveAgain", (seconds)); gameObject.SetActive(false); } } function LiveAgain() { gameObject.transform.position = spawnPoint.position; gameObject.SetActive(true); } How could I make it so then the variable "lives" is changed back to it's original value after spawning again?(For example, if lives was originally ten, I would want it to be 10 after it spawns again at "spawnPoint")

Viewing all articles
Browse latest Browse all 171066

Trending Articles



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