← Back to all addons

EXP Bar Add-On

Posted by Jables on May 21, 2025 at 4:03 PM

GameplayExperimentalFeature3.0 Verified
❤️ 4 💡 3 🔥 1

Experience Bar Implementation Guide

1. UI Setup

plaintext
1. Open the User Interface prefab, Duplicate Mana Bar in your HUD
2. Rename to "ExperienceBar"
3. Remove UIStatBar component
4. Add UIExperienceBar component (will be attatched to this guide)
5. Customize stuff

2. Verify Hero.cs

// Ensure these properties exist:
public int experience => m_experience;
public int nextLevelExperience => GetTotalExpRequirement(m_level + 1);

// Verify experience field:
private int m_experience = 0;

3. NotificationSystem.cs

// Verify these events exist:
public UnityEvent<int> experienceGained = new();
public UnityEvent<int> levelUp = new();

4. Constants.cs

// Verify these constants:
public const int MinLevel = 1;
public const int MaxLevel = 100;

The UIExperienceBar component will handle all the animations and updates automatically once these pieces are in place. There are options for animation duration, pulsing color, etc. to help you customize your level up experience. Also, by default if you followed the guide, the EXP bar will be at the top grouped with the Player HP and MP. To change this and put the EXP bar anywhere you want, just drag the Exp Bar game object outside of the “Resource Bars” game object to free it from it’s captivity! I’m sure i probably forgot something, as is my nature, but I hope you guys enjoy watching the EXP go up as much as I do!! Feel free to edit to your hearts content!

For the MAX player level in constants, I’m pretty sure you can put it to whatever you want without breaking anything. I just have mine set to max level 100 with a requirement of 4.9 mil exp to reach because… grindfest

📜 Scripts

💬 Comments (40)

Mr.Titan May 21, 2025 at 07:41 PM
this is nice! 🔥
❤️ 1
8Bit Rpg May 30, 2025 at 06:55 AM
Hey @Jables, how are you? Very good addon by the way! Maybe someone else has had the problem where the first enemy you kill doesn’t update the bar. Starting with the second one, it does, but it remains as an enemy behind, so it’s missing the experience value of the first enemy killed.
Jables May 30, 2025 at 07:01 AM
If you could, can you take a short video clip for me of you killing the first enemy and not getting the experience? I just need to see a few details and I’ll be able to debug
8Bit Rpg May 30, 2025 at 07:02 AM
I’m on it
Jables May 30, 2025 at 07:02 AM
I’m thinking, if you are doing this from a fresh new Mythril2D project, it could be that the first skeleton in the demo actually has its own set of events with an exp gain rather than a player call.. but that’s just an assumption - I’ll see what’s up
Jables May 30, 2025 at 07:03 AM
Also what Unity version are you using
8Bit Rpg May 30, 2025 at 07:04 AM
Unity 6 (6000.0.44f1)
8Bit Rpg May 30, 2025 at 07:04 AM
Jables May 30, 2025 at 07:05 AM
Alright I’ll hop on it, I’ll be back with an answer as soon as I solve it
8Bit Rpg May 30, 2025 at 07:06 AM
Thank you!
❤️ 1
Jables May 30, 2025 at 07:06 AM
It also looks like it’s 1 exp point shy of being accurate as well
Jables May 30, 2025 at 07:06 AM
Strange
Jables May 30, 2025 at 07:06 AM
Have you edited the hero script at all?
8Bit Rpg May 30, 2025 at 07:07 AM
It seems that instead of updating the bar normally the first time, it sends the event to the queue and from the second enemy onwards it continues to play that queue.
8Bit Rpg May 30, 2025 at 07:08 AM
Nope
Jables May 30, 2025 at 07:09 AM
Most curious
Jables May 30, 2025 at 07:09 AM
I’m looking into it, I’ll be back as soon as I can
Jables May 30, 2025 at 07:16 AM

📜 Scripts

Jables May 30, 2025 at 07:16 AM
Try my hero.cs, just in-case i forgot to mention any possible changes to it, which could be likely
Jables May 30, 2025 at 07:17 AM
I dont remember having to do any edits to it, but i feel like its a possibility
Jables May 30, 2025 at 07:17 AM
still exploring other fixes as well though
Jables May 30, 2025 at 07:18 AM
just havent been able to re-create the issue yet
8Bit Rpg May 30, 2025 at 07:27 AM
yeyyyyyy
Jables May 30, 2025 at 07:28 AM
the hero.cs worked?
8Bit Rpg May 30, 2025 at 07:28 AM
The answer is here
❤️ 1
Jables May 30, 2025 at 07:28 AM
i was just about to tell you to edit the addexperience method with this
8Bit Rpg May 30, 2025 at 07:29 AM
You added this:
8Bit Rpg May 30, 2025 at 07:29 AM
if (level <= Constants.MinLevel) return 0;
8Bit Rpg May 30, 2025 at 07:29 AM

and the addexperience method is changed with this at the final

GameManager.NotificationSystem.experienceGained.Invoke(experience);

8Bit Rpg May 30, 2025 at 07:30 AM
instead of above: m_experience += experience;
❤️ 1
Jables May 30, 2025 at 07:31 AM
Well dang! Send a clip of the first enemy working? I’ll pin this an official fix for the add on if i can
8Bit Rpg May 30, 2025 at 07:32 AM
yep
Jables May 30, 2025 at 07:33 AM
Opa I dont think I have pinning powers
8Bit Rpg May 30, 2025 at 07:33 AM
❤️ 1 m2d 1 🍻 1
Jables May 30, 2025 at 07:34 AM
Awesome!!
❤️ 1
8Bit Rpg May 30, 2025 at 07:34 AM
Thanks for the help! I really appreciate it!
🍻 1
Jables May 30, 2025 at 07:35 AM
And that odd 1 exp point is back to normal as well good to see!
Jables May 30, 2025 at 07:35 AM
You figured it out before I could 😉 I appreciate your help good sir!
🫡 1
Zuko Sep 01, 2025 at 03:03 PM

Sorry for my ignorance, I don’t have much experience with C# or programming in general, but I do use some scripts in my game. For this experience bar one, do I just create a MonoBehaviour with the script you added, or do I need to change something inside the code?

From what I understood, it’s just a matter of following what’s in the UI setup and then configuring things in the Inspector.

Did I get that right, or is there anything else I need to do?

Sorry for the silly questions, but I’m new to gamedev in general.

@Jables sorry for the ping, i dont know if you receive notifications from old posts

Want to continue the conversation?