#Health

1 messages · Page 1 of 1 (latest)

left tundra
#

And what exactly doesn’t work?

quick hemlock
#

Its supposed to change the code in the static class

#

i mean number

#

ss

#

heres the class

left tundra
#

These are all primitive datatypes, meaning that declaring a new variable on them basically copies their value.

#

So when PlayerDataStatic.mentalC is false at the beginning at then set to true, HealthSystem would not know about it.

#

And just like that, HealthSystem wouldn’t know about any changes you do to PlayerDataStatic.

#

Also, don't abuse static like this. Static means that your field belongs to the type rather than to an object, what definitely is not the case here.

quick hemlock
#

I’m trying to save data from player through scenes without the player being in it. I tried DontDestroyOnLoad and that just didn’t work

#

I want the data from the player to be changed and saved

left tundra
#

Use DontDestroyOnLoad or SceneLoadMode.Additive to load a place above another.

#

Change the references in your Update() method in HealthSystem to access PlayerDataStatic directly, then try again.

quick hemlock
left tundra
#

Then create a new GameObject, put your PlayerData component on it and then call DontDestroyOnLoad() on it.

quick hemlock
left tundra
#

Rename it to PlayerData and remove all static modifiers.