Getting the remainder of a number

Hi, I am working on a XP system for my game. I think I have got the basics sorted, but I am having trouble thinking of something.

I have made the system and it’s all working fine, so far. But I’m curious how to get a remainder of a number.

So as most of you will know, the Image.FillAmount only goes up to 1. So I am using the current level (lets say level 10) and dividing it by 10.

When the player levels up, if there is any xp left over from the previous level I want to add it to the current xp level.

Not sure if that makes sense, so I’ll try to explain better.

Say that the player is on level 10 and is 100XP away from level 11 and they get 120XP somehow. How would I be able to add the 100XP to the current XP level and then when they hit 11 the script automatically adds the 20 to the next level?

I know this sounds so confusing, as I have just reread through it, but not sure how else to word it. My mind is frazzled as I have been coding for about 10 hours straight. Any help would be very appreciated.

I am Using C# by the way

Modulus will solve this.

2 Likes