Hello!
I´m making the health system of my player but i have a problem when i try to subtract a variable… here is the code:
using UnityEngine;
using System.Collections;
public class SaludEnemigo : MonoBehaviour {
public int salud = 100;
public int cursalud = 100;
public int dano = 10;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if (cursalud < 1)
cursalud = 1;
if (cursalud > 100)
cursalud = 100;
}
void HacerDano(){
cursalud - dano; //here is the problem
}
void OnTriggerEnter (Collider dagger){
HacerDano();
}
}
The script is in spanish i make a few traductions:
salud = health
cursalud = current health
dano = damage
HacerDano = make damage
And here is the problem that reports the editor:
Assets/Scripts/SaludEnemigo.cs(28,32): error CS0201: Only assignment, call, increment, decrement, and new object expressions can be used as a statement
See you!
AW:i now that the script is really “basic” but i´m starting with the Triggers .