I am using unity community levelup script. Don’t know how to rewrite a script. Trying to understand how this script well work for what I want.
Lets say theres 20 levels would I need to repeat the code for each level?
GainExp would I change that to Dying Enemy, so whenever the player kills an enemy they get exp from that?
Whats Jump for?
For the leveling Methods not sure which one to use or understand them?
hope someone can explain it to me.
using UnityEngine;
using System.Collections;
public class Experience : MonoBehaviour
{
//current level
public int vLevel = 1;
//current exp amount
public int vCurrExp = 0;
//exp amount needed for lvl 1
public int vExpBase = 10;
//exp amount left to next levelup
public int vExpLeft = 10;
//modifier that increases needed exp each level
public float vExpMod = 1.15f;
//vvvvvv USED FOR TESTING FEEL FREE TO DELETE
void Update ()
{
if (Input.GetButtonDown("Jump"))
{
GainExp(3);
}
}
//^^^^^^ USED FOR TESTING FEEL FREE TO DELETE
//leveling methods
public void GainExp(int e)
{
vCurrExp += e;
if(vCurrExp >= vExpLeft)
{
LvlUp();
}
}
void LvlUp()
{
vCurrExp -= vExpLeft;
vLevel++;
float t = Mathf.Pow(vExpMod, vLevel);
vExpLeft = (int)Mathf.Floor(vExpBase * t);
}
}