Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by cilayin · Apr 28, 2014 at 08:35 AM · c#character

Exponential XP (Beginner)

I'm relatively new to any sort of coding; C# especially.

I'm still learning and I know this might seem pretty trivial but I'm trying to figure out how to go about making a xp/leveling system that goes off of xp that isn't of a liner fashion. IE. Not, 50, 100, 150, etc.

Obviously, you could math it out and set the xp req per level. But is there a way I can do it with just a couple lines of code? And would you have to change anything as far as the typical "leveling" scripts go?

If you had something like:

 if(currentXP >= nextLvlXP(currentLVL))
     {
     currentLVL+=1;
     }



Or would you have to make some changes to it?

Also, I was looking for some examples or reference but, I'm not sure if this is what I'm looking for.

MSDN

And I'm sorry if the code sample didn't work, I clicked on it and used it however it doesn't look like the code that's shown like in everyone's posts here (Although maybe it just doesn't show up in preview?).

Thanks for the time! :) Hopefully I explained myself well enough (I'm tired!) And, does anyone else have a ridiculously hard time with tags?

EDIT: Broken link was broken.

Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Benproductions1 · Apr 28, 2014 at 09:36 AM 0
Share

Ins$$anonymous$$d of doing what you would do in a linear fashion, you'd add an exponential to the calculation. You should post nextLvlXP.

avatar image Tarlius · Apr 28, 2014 at 11:22 AM 0
Share

Be careful not to forget to check for whether the player gained enough exp to level up twice. In your pseudo-code if the player gets enough xp to level up twice it looks like they'll only level up once.

1 Reply

· Add your reply
  • Sort: 
avatar image
3
Best Answer

Answer by Bunny83 · Apr 28, 2014 at 10:15 AM

As you can easily find on the net, most games ( which involves XP )seem to be based on a quadratic function and not exponential. The exponential function has the "little" problem that it grows way too much when you go higher. You could compensate it a bit by increasing the XP gain with each level also in a exp-fashion.

If you have a XP <-> level relation ship based on the quadratic function like this:

     level = Mathf.FloorToInt(constant * Mathf.Sqrt(XP));

You can calculate the required XP for a certain level like this:

     XP = (level*level) / (constant*constant);


Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image cilayin · Apr 28, 2014 at 02:51 PM 0
Share

Thanks a bunch! :)

avatar image babasuter cilayin · Apr 28, 2014 at 03:11 PM 1
Share

I think answers should be reserved for actual answers, not comments.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

24 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Multiple Cars not working 1 Answer

My character jumps infinitely, even when in mid-air 1 Answer

Distribute terrain in zones 3 Answers

Edit this code? 0 Answers

Pushing More GUI Clips Than Popping 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges