Hey Guys
i need some help
for some reason my experience system wont work, as far as i can remember this is the same way i had my code set out in a previous project(cant find this project, hence the need to recode)
its not adding the xp and levels when i collide with the “XPOrbs” and its not destroying the xporb on contact
when i just had the system set so that if i hit “Space” then i would gain XP and that worked perfectly but now nothing happens
any help would be greatly appreciated
using UnityEngine;
using System.Collections;
public class XPSystem : MonoBehaviour
{
public float minXp;
public float xpNeeded;
public float currentXp;
public float currentLevel;
void Awake () {
}
void OnCollisionEnter(Collider collider)
{
switch (collider.gameObject.tag)
{
case "XPOrb":
Destroy (this.gameObject);
break;
}
}
void Update () {
if (collider.gameObject.tag == "XPOrb")
{
currentXp += 10f;
}
if (currentXp < minXp)
currentXp = minXp;
if (currentXp >= xpNeeded)
{
LevelUp();
}
}
void LevelUp() {
currentLevel ++;
currentXp = 0f;
xpNeeded += 100f;
}
}