playerdamage not working. help fix?
so I have a good bit of stuff I had to so with this. i needed to make the gui picture, which works(99% sure) and i need to get the enemy to take damage when touching. here is the script: using UnityEngine; using System.Collections; public class playerhealth : MonoBehaviour { public ImagePosition healthbar; public float max_health = 100f; public float cur_health = 0f; public bool alive = true; private void Start() { alive = true; cur_health = max_health; SetHealthBar(); InvokeRepeating("doDamage", 1f, 5f); } void DoDamage() { TakeDamage(10f); } public void TakeDamage(float amount) { if (!alive) { return; } if (cur_health <= 0) { cur_health = 0; alive = false; // gameObject.SetActive(false); } cur_health -= amount; SetHealthBar(); } public void SetHealthBar() { float my_health = cur_health / max_health; healthbar.transform.localscale = new Vector3(Mathf.Clamp(my_health, 0f, 1f), healthbar.transform.localScale.y, healthbar.transform.localScale.z); } }
Unity says that it does not know what transform is, and I do not know why.thanks