- Home /
Experience Points + Level up for RPG?
I need your help.
do you know how to make a script for Xp and how to make each level up add variables to the character status so for ex.
LEVEL UP
- magic
- armor
- item lvl (for items that require a lvl)
What do you mean by "making a script for XP"? Assu$$anonymous$$g you mean "XP" as in "Windows XP", it does not matter what OS you use for Unity - all scripts, once compiled, run the same everywhere.
XP = eXperience Points, with regards to RPG-like elements (Experience, leveling up, new abilities, etc).
will the script that is handling level up also handle the state's?
Answer by _Petroz · Jun 24, 2010 at 08:31 AM
Make XP a member variable of the character script. Then increase that value when appropriate and alter other variables when the character level ups.
pseudocode:
var currentXP = 0; var nextLevelUp = 100;
gainExperience(int amount) { currentXP += amount; if (currentXP >= nextLevelUp) { levelUp(); } }
levelUp() { nextLevelUp += 100; maxHealth += 10; }
Answer by Unamine · Feb 18, 2011 at 01:00 PM
See the tutorials: Burg Arcade Zerg, he teaches how to create an RPG that and also complete step-by-step check out this link:
http://www.burgzergarcade.com/hack-slash-rpg-unity3d-game-engine-tutorial
- Unity3d Tutorial - Character Statistics 1/7
- Unity3d Tutorial - Character Statistics 2/7
- Unity3d Tutorial - Character Statistics 3/7
- Unity3d Tutorial - Character Statisics 4/7
- Unity3d Tutorial - Character Statisics 5/7
- Unity3d Tutorial - Character Statisics 6/7
- Unity3d Tutorial - Character Statisics 7/7
Answer by poncho · Feb 18, 2011 at 04:06 PM
in this case is easier just to watch your lvl and experience also having an "available status points" variable
var currentXP =0; var currentLVL=1; var maxHealth=0; var maxMagic=0;
//most RPG games use formulas to get the next lvl experience, thats why each lvl you need more experience
newExperience(int exp)
{
currentXP+=exp;
if(currentXP >= nextLvlExp(currentLVL))
{
currentLVL+=1;
getNewStats();
}
}
getNewStats() { getHealth(currentLVL); getMagic(currentLVL); }
getHealth(int lvl) { //this is an example it will be 42 lvl1, 50 lvl2, 58 lvl3, 72 lvl4, etc... maxHealth = 40 + lvl*lvl*2; }
getMagic(int lvl) { //some games depend on lvl + magic stats(or intelligence) + items maxMagic = 10 + lvl*lvl + stats.magic*3 + gear.weapon.magic*2; }
//trying to equip an item is verified on the moment you try to use it newGear(gear item) { if(item.minLvl < currentLVL) { //if cannot be equipped dont allow the usage of the item denyNewGear(); } }
this is common scripting on RPG games, hopes this helps you
I am just learning scripting but this is an amazing example, anyone should be able to start with something like this, thanks.
Your answer
Follow this Question
Related Questions
Can someone help me fix my Javascript for Flickering Light? 6 Answers
Setting Scroll View Width GUILayout 1 Answer
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
Function variable problem. 1 Answer
Sequence of function Calls 2 Answers