What I love about your channel is that you explain the same things that everyone else is, but you are following the "Explain Like I'm Five" methodology, which is absolutely what I need. Thank you for making these concepts super understandable!!
This was super helpful! If you feel so inclined ;) implementing some kind of Level Up mechanic for implementing a skill tree in a "series" style of video would be great.
Not gonna lie, I kinda gave up on learning C# and Unity for the moment, but whenever I decide to get back to it, your channel is going to be a main resource.
Just found your videos, I like your pacing and how you structure your videos so thank you :). Currently watching your scriptable objects (referencing Fine/Hipple talks) and am now watching this video. I'm going to try and implement this system while using scriptable objects. If you were so inclined maybe a followup video to this one changing it to use ScriptableObjects as well. I'm sure I'll be able to meld the two together but any further insight/examples are always appreciated. Perhaps scriptable objects for events Thanks again
How do you address the issue if you save the project, you get an error of NullReferenceException: Object reference not set to an instance of an object PlayerHealth.OnEnable () (at Assets/Scripts/PlayerHealth.cs:16) . Everything works fine until you save and restart it.
Remember to put the ExperienceManager script to an object in the scene besides the character (its best to create an object only with this script attached to it)
If you are getting "NullReferenceException: Object reference not set to an instance of an object", and you've followed the tutorial to the point - one solution would be to go into Edit > Project Settings > Script Execution Order and add both scripts Experience Manager (ex value: 100) and Character (ex value: 200). This will make the Experience Manager run first, and Character second. The issue comes from the difference in execution times/order between Awake methods and OnEnable methods.
This shouldn't happen since Awake is called before OnEnable, so if that's happening, there could be some other problem in the code/setup. Generally, you shouldn't resort to changing the script execution order.
You can fix this error without manipuliating the execution order(I also recommend it because changing it can lead to funny errors). This error usally happens when you have an Awake() function somewhere in your code that requires and Object/Prefab that uses the ExpereinceManager methods, because the OnEnable() method is executed after the Awake() function so it requires the object before it is enabled leading to the null Reference Exception. So in short.... Dont use Awake() when possible always use Start()
I checked for Awake in every script i have and tried every other fix and nothing worked except doing what you reccomended. i would reccomend any else having problems to try what @Charybdis47 is saying and pretty much replace all awakes except for the experienceManager and if that doesnt work try editing the script execution order. This is very last resort, and I spent hours before resorting to this.
Can I have it as a child object that empty object which detects collecting exp in case that I do rpg? So when I am far away so it accidentally doesn’t stop count or when I leave the scene so it keeps the values from previous level and so on. Or I have to always create a new empty object containing this exp manager script
For some reason, all of the code worked at first, but when i closed and reopened my project, all the experience gain just stopped working. The hp all worked fine, but the exp gain was not working. Does anyone know the solution to this?
This error usally happens when you have an Awake() function somewhere in your code that requires and Object/Prefab that uses the ExpereinceManager methods, because the OnEnable() method is executed after the Awake() function so it requires the object before it is enabled leading to the null Reference Exception. So in short.... Dont use Awake() when possible always use Start()
If you have this Error:*NullReferenceException: Object reference not set to an instance of an object* Follow this: You can fix this error without manipuliating the execution order(I also recommend it because changing it can lead to funny errors). This error usally happens when you have an Awake() function somewhere in your code that requires and Object/Prefab that uses the ExpereinceManager methods, because the OnEnable() method is executed after the Awake() function so it requires the object before it is enabled leading to the null Reference Exception. So in short.... Dont use Awake() when possible always use Start()
@@hazen7645 it seems you have misunderstood my comment. I am not talking about the awake function from the experience manager class, but another class that may use the events that this function enables. Then it triggers an error like this, because it tries to acess the Manager which hasnt been enabled yet with OnEnable(). Thats why I suggested to only use Awake() when truly necessary which is almost never. I didnt suggest to not use Awake() in the ExperieninceManager. All you do is confuse people who got this error like me. Just look at the comments....
@@hazen7645 listen buddy I dont know why you try to start an argument even tho I explained it 2 times already but here we go again..... You have the player class which has OnEnable() and OnDisable() which subscribe or unsubscribe to the ExerienceManager method. This player object can be called at the start of the game to spawn on 1 or more player prefabs that have this script attached. When you work with a bad codebase LIKE I DID, in the spawnScript there was an Awake() function which instantiated a player prefab which couldnt call the OnEnable() method ,because Awake() triggered it to early, causing a NullReferenceException. THEREFORE I said dont use Awake() only when you dont have to cause it can cause funny Errors like that. It has NOTHING to do with the Awake() method in ExperienceManager class. Will you say I dont understand this again yes??
@@hazen7645 i literally said:"error usually happens when you have an Awake() function somwhere in your code that requires and Object/prefab that uses the ExperienceManager methods" bro learn to read before you write instead of accusing me of being stupid💀
You can fix this error without manipuliating the execution order(I also recommend it because changing it can lead to funny errors). This error usally happens when you have an Awake() function somewhere in your code that requires and Object/Prefab that uses the ExpereinceManager methods, because the OnEnable() method is executed after the Awake() function so it requires the object before it is enabled leading to the null Reference Exception. So in short.... Dont use Awake() when possible always use Start()
You can fix this error without manipuliating the execution order(I also recommend it because changing it can lead to funny errors). This error usally happens when you have an Awake() function somewhere in your code that requires and Object/Prefab that uses the ExpereinceManager methods, because the OnEnable() method is executed after the Awake() function so it requires the object before it is enabled leading to the null Reference Exception. So in short.... Dont use Awake() when possible always use Start()
What I love about your channel is that you explain the same things that everyone else is, but you are following the "Explain Like I'm Five" methodology, which is absolutely what I need. Thank you for making these concepts super understandable!!
Didn't sign up for the event system tutorial, but I'm thankful for it. Great stuff!
This was super helpful!
If you feel so inclined ;) implementing some kind of Level Up mechanic for implementing a skill tree in a "series" style of video would be great.
Not gonna lie, I kinda gave up on learning C# and Unity for the moment, but whenever I decide to get back to it, your channel is going to be a main resource.
have you got back to learning?
dude you are a gem
So useful , great, thank you
Just found your videos, I like your pacing and how you structure your videos so thank you :). Currently watching your scriptable objects (referencing Fine/Hipple talks) and am now watching this video. I'm going to try and implement this system while using scriptable objects. If you were so inclined maybe a followup video to this one changing it to use ScriptableObjects as well. I'm sure I'll be able to meld the two together but any further insight/examples are always appreciated. Perhaps scriptable objects for events
Thanks again
me voy a suscribir a tu canal, tus videos son en verdad buenos
Very concise. Thank you!
How do you address the issue if you save the project, you get an error of NullReferenceException: Object reference not set to an instance of an object
PlayerHealth.OnEnable () (at Assets/Scripts/PlayerHealth.cs:16)
. Everything works fine until you save and restart it.
Does everything break? Or just the exp?
Since i am having the same issue, i need to know if you have the answer
@@gamingprochampion5822 let me know if you ever figure out what is wrong
Remember to put the ExperienceManager script to an object in the scene besides the character (its best to create an object only with this script attached to it)
Did you ever find a fix for this?
So weird seeing Isaac smile
this is awsome
How did you setup the XP Progress bar at the start of the video? How do you make it?
i think you make a slider object in the ui canvas and set it to be equal to the current experience through an update method.
If you are getting "NullReferenceException: Object reference not set to an instance of an object", and you've followed the tutorial to the point - one solution would be to go into Edit > Project Settings > Script Execution Order and add both scripts Experience Manager (ex value: 100) and Character (ex value: 200). This will make the Experience Manager run first, and Character second.
The issue comes from the difference in execution times/order between Awake methods and OnEnable methods.
This shouldn't happen since Awake is called before OnEnable, so if that's happening, there could be some other problem in the code/setup. Generally, you shouldn't resort to changing the script execution order.
You can fix this error without manipuliating the execution order(I also recommend it because changing it can lead to funny errors). This error usally happens when you have an Awake() function somewhere in your code that requires and Object/Prefab that uses the ExpereinceManager methods, because the OnEnable() method is executed after the Awake() function so it requires the object before it is enabled leading to the null Reference Exception. So in short.... Dont use Awake() when possible always use Start()
You should use Invoke() to delay the OnEnable and OnDisable for 0.2 seconds
I checked for Awake in every script i have and tried every other fix and nothing worked except doing what you reccomended. i would reccomend any else having problems to try what @Charybdis47 is saying and pretty much replace all awakes except for the experienceManager and if that doesnt work try editing the script execution order. This is very last resort, and I spent hours before resorting to this.
Really amazing Tutorials! Can you make one all about like coins and shop systems.
Can you show a tutorial for the ui in the intro?
Can I have it as a child object that empty object which detects collecting exp in case that I do rpg? So when I am far away so it accidentally doesn’t stop count or when I leave the scene so it keeps the values from previous level and so on. Or I have to always create a new empty object containing this exp manager script
For some reason, all of the code worked at first, but when i closed and reopened my project, all the experience gain just stopped working. The hp all worked fine, but the exp gain was not working. Does anyone know the solution to this?
Have you checked if you have any other EventSystem or maybe anything disabling your gameObject tha has the Character.cs script?
This error usally happens when you have an Awake() function somewhere in your code that requires and Object/Prefab that uses the ExpereinceManager methods, because the OnEnable() method is executed after the Awake() function so it requires the object before it is enabled leading to the null Reference Exception. So in short.... Dont use Awake() when possible always use Start()
If you have this Error:*NullReferenceException: Object reference not set to an instance of an object* Follow this: You can fix this error without manipuliating the execution order(I also recommend it because changing it can lead to funny errors). This error usally happens when you have an Awake() function somewhere in your code that requires and Object/Prefab that uses the ExpereinceManager methods, because the OnEnable() method is executed after the Awake() function so it requires the object before it is enabled leading to the null Reference Exception. So in short.... Dont use Awake() when possible always use Start()
still doesn't work for me
any other ideas?
@@hazen7645 it seems you have misunderstood my comment. I am not talking about the awake function from the experience manager class, but another class that may use the events that this function enables. Then it triggers an error like this, because it tries to acess the Manager which hasnt been enabled yet with OnEnable(). Thats why I suggested to only use Awake() when truly necessary which is almost never. I didnt suggest to not use Awake() in the ExperieninceManager. All you do is confuse people who got this error like me. Just look at the comments....
@@hazen7645 listen buddy I dont know why you try to start an argument even tho I explained it 2 times already but here we go again..... You have the player class which has OnEnable() and OnDisable() which subscribe or unsubscribe to the ExerienceManager method. This player object can be called at the start of the game to spawn on 1 or more player prefabs that have this script attached. When you work with a bad codebase LIKE I DID, in the spawnScript there was an Awake() function which instantiated a player prefab which couldnt call the OnEnable() method ,because Awake() triggered it to early, causing a NullReferenceException. THEREFORE I said dont use Awake() only when you dont have to cause it can cause funny Errors like that. It has NOTHING to do with the Awake() method in ExperienceManager class. Will you say I dont understand this again yes??
@@hazen7645 i literally said:"error usually happens when you have an Awake() function somwhere in your code that requires and Object/prefab that uses the ExperienceManager methods" bro learn to read before you write instead of accusing me of being stupid💀
NullReferenceException: Object reference not set to an instance of an object
You can fix this error without manipuliating the execution order(I also recommend it because changing it can lead to funny errors). This error usally happens when you have an Awake() function somewhere in your code that requires and Object/Prefab that uses the ExpereinceManager methods, because the OnEnable() method is executed after the Awake() function so it requires the object before it is enabled leading to the null Reference Exception. So in short.... Dont use Awake() when possible always use Start()
@@Charybdis47 What does that mean? I don't get it
I have the same issue, I just made the OnExperienceChange event static in the ExperienceManager class and it works. hope it helps
@@yensi1994 how did you do that? I tried that as well but then I get another error
It all worked until i reloaded, at which point the exp gain stopped working. how do i fix this?
You can fix this error without manipuliating the execution order(I also recommend it because changing it can lead to funny errors). This error usally happens when you have an Awake() function somewhere in your code that requires and Object/Prefab that uses the ExpereinceManager methods, because the OnEnable() method is executed after the Awake() function so it requires the object before it is enabled leading to the null Reference Exception. So in short.... Dont use Awake() when possible always use Start()
You could have explained the stuff in more detail...
I will unsubscribe from the event but never from this channel
I will add this
This was hot
Outro tune is a jam
perfect,
Pog
NullReferenceException: Object reference not set to an instance of an object
It signals that you haven't put the object in unity that you want to reference in the script