what is wrong here trying to make my player take damage by a projectile
this is the error Assets\HealthBar.cs(30,4): error CS0201: Only assignment, call, increment, decrement, await, and new object expressions can be used as a statement
this is the code
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI;
public class HealthBar : MonoBehaviour { public float health; public Slider slider; public Gradient gradient; public Image fill;
public void SetMaxHealth(int health)
{ slider.maxValue = health;
slider.value = health;
fill.color = gradient.Evaluate(1f);
}
public void SetHealth(int health) {
slider.value = health;
fill.color =
gradient.Evaluate(slider.normalizedValue); } void OnCollisionEnter(Collision obj) { if (obj.gameObject.tag=="Projectile") health - health - 1f; }
}
Comment