pay for scripts

I know it sounds like a cop out but I have hit a deadend. Don’t get me wrong…I love learning this scripting and have learned a lot and done a lot, but I am 55 years old and this “hobby” has consumed me to where I am spending too much time battling what I am finding impossible. I have been able to figure all sorts of stuff out but what has me going insane is saving data. I have read all the posts and forums and every youTube video known to man but nothing works. Either a laundry list of errors or no functionality. As is, when I hit SAVE I successfully SetInt of the player transform and the level to playerPrefs and they LOAD fine. But I didn’t write this script, it’s a JS script I dredged up online. I have studied it but to no avail as far as trying to recreate that for saving three other variables. I want to save/store: player score, player health, and a stamina powerup. Again…feels like a cheesy cop out to not try to figure this out but I have wasted too much time already with ZERO results. public static didn’t work without being one of those failed attempts when I tried to save the health because 3 other scripts that access the player health could then not read it. with this error: Assets/EnemyAttack.cs(66,34): error CS0176: Static member `PlayerHealth.currentHealth’ cannot be accessed with an instance reference, qualify it with a type name instead"
for the code lie which reads:
if(playerHealth. currentHealth > 0)

" qualify it with a type name instead"? what does that even mean?

name your price. i have more money than time.
you can spare the lectures on how crappy playerPrefs for saving data because I am not really worried about someone being able to hack the score as there will be no leaderboard

Class Members/Variables(i.e. static)

When a member of a class(properties or fields) are marked as static, it is to say this static member is accessible by the class. This means one variable exists for all references to that class.

Example:

public class SomeClass : MonoBehaviour
{
    public static int _score = 0;
    public int _playername = "Player1";
}

The above can be accessed without instantiating an object manually since the variable is a class member rather then an instance member(think using the keyword new) and can be set/get by qualifying with the class name such as:

SomeClass._score; // get
SomeClass._score = 20; // set

The above could be done without ever doing

SomeClass sc = new SomeClass(); // Creating an instance of SomeClass

Instance Members

The above class called SomeClass has a class member(_score) and an instance member (_playername).
If you tried accessing _playername like _score you would get an exception. Because it’s an instance member you must instantiate the object first before it’s accessable. Each instance will have their own reference to the instance members, but all share the same class members(static).

example:

SomeClass._playername = "todd"; // would throw an exception like An object reference is required for the non-static field, method, or property 'SomeClass._playername'"
SomeClass sc1 = new SomeClass();
Debug.Log(sc1._playername); // will print to the console "Player1" since thats the strings initialized value.

SomeClass sc2 = new SomeClass();
sc2._playername = "todd";
Debug.Log(sc1._playername); // will print to the console "Player1" since thats the strings initialized value.
Debug.Log(sc2._playername); // will print to the console "Todd" since we changed it after we instantiated it.

If you tried to get the score from the instance like:

Debug.Log(sc1._score); // would throw the error you're getting now.

In the last case _score was accessed by the instance of SomeClass type called sc1, but it’s a class member and not an instance member, it needs to be accessed outside of the class by qualifying the class/type name in front.

Debug.Log(SomeClass._score); // would print '0' in the console.

So for all SomeClass instances regardless of what they are called or where they are used, they all share a static member on the class called _score, there isn’t a separate value for each instance