|
Hi, I have a problem with a respawn script! I use a var called canSpawn that in Start() function is false. When a player is killed I use this code to wait x seconds deadTime = respawnTimer += Time.time; This code is placed in a RPC function. My update function is this: Debug.Log("can spawn"); is printed so I fiugre that canSpawn is true. The problem is that if I place an if statement like this: if (canSpawn) in the RPC function (the same of the deadTime = respawnTimer += Time.time; code), this if is never called. Why? Thanks a lot, Marco
(comments are locked)
|
|
It happens because of scope. A variable gets disposed of every time the program exits the block it was declared in. If you want your variable to be accessible from everywhere in your script, declare it at class level.
(comments are locked)
|
