|
Unity freezes when im applying this script to a Gameobject. I can't see whats wrong with my script, i did a lot of changes, but i can't really see what's wrong. my class name and the script's name is the same.
{
}
(comments are locked)
|
|
You can't call the constructor (as you do in the sixth line of your code, "var health = playerStats ()") of a MonoBehaviour. MonoBehaviours are, in essence, constructed when you add them as a component to something (That's why they have "Awake" and "Start"). Try taking out that assignment and you won't have any problem. However, I'm guessing then that your script won't function as you intend. It looks like you're trying to create a singleton. You might take a look at the wiki article on that topic. It's in C#, but the process for creating a single instance of some MonoBehaviour should be evident. As a side note, classes are typically defined starting with a capital letter (ie, "class PlayerStats") to avoid confusion with variables, which should be named starting with a lowercase letter (ie, "var maximum").
(comments are locked)
|
|
What happens is an instance of your In effect, you created an endless cycle.
(comments are locked)
|
