Question by
supervagito · Jun 10, 2017 at 09:35 AM ·
c#scripting problem
How to add points upon destroying something .
i have a Level Up system script and i have an enemy script i want to make if the enemy is destroyed the experience points increases by an amount but i want all the objects that has the enemy script can i do that or do i use the tag method and thanks how can i do it i don't know how to access scripts through other scripts so please help, this is the level Up system script :
public int level;
public float experience;
public float experienceRequired;
public float Hp;
void Start ()
{
level = 1;
experience = 0 f;
experience Required = 200 f;
Hp = 150 f;
}
void Update ()
{
Exp ();
}
void Rank Up()
{
level += 1;
experience = 0;
}
void Exp()
{
if (experience >= experience Required)
{
Rank Up ();
experience Required = experience Required * 2;
Hp = Hp * 2;
}
}
} and this is the enemy script : public int health = 50;
public void take damage(int damage)
{
health -= damage;
if (health <= 0)
{
Destroy (game Object);
}
}
and thanks
Comment
Your answer
Follow this Question
Related Questions
unable to attack enemy objects? 1 Answer
Rayscast from the GameObject that is not the player does not work 0 Answers
How can i run a script with a single key press? 1 Answer
Correctly smooth crouch script? 2 Answers
Translate C# into Javascript 0 Answers