Hi everyone! Help to solve problem! I need that script to read “health” from Properties!(And script Properties is attached to the chacacter with tags “Air” and “Ground”)
Can not understand what is not right.
`using UnityEngine;
using System.Collections;
public class Power_ups : MonoBehaviour {
public float Health;
public GameObject bullet;
public float damage = 100;
public GameObject btn_power_up;
void Awake(){
bullet.SetActive(false);
}
void Start(){
UIEventListener.Get(btn_power_up).onClick += PowerStart;
}
void PowerStart (GameObject btn_power_up) {
bullet.SetActive(true);
}
void OnTriggerEnter ( Collider hit ){
if(hit.gameObject.tag == "Air")
{
bullet = hit.gameObject;
TakeDamage();
}
if(hit.gameObject.tag == "Ground")
{
bullet = hit.gameObject;
TakeDamage();
}
}
void TakeDamage (){
health properties = GetComponent<Properties>();
Health = properties.health;
Health -= damage;
}
}
`