Ejemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        tankHealth targetHealth = target.GetComponent <tankHealth>();

        if (!targetHealth)
        {
            return;
        }
        hpSlider.value = targetHealth.HPpercent();

        if (hpSlider.value <= 0f)
        {
            hpSlider.gameObject.SetActive(false);
        }
        else
        {
            hpSlider.gameObject.SetActive(true);
        }

        Vector3 tarPos;

        tarPos = target.transform.position;
        Vector2 pos = RectTransformUtility.WorldToScreenPoint(Camera.main, tarPos);

        hpSlider.transform.position = pos + offsetPos;
    }
Ejemplo n.º 2
0
    // Update is called once per frame
    void Update()
    {
        tankHealth targetHealth = target.GetComponent <tankHealth>();

        if (!targetHealth)
        {
            return;
        }
        hpSlider.value = targetHealth.HPpercent();

        Vector3 tarPos;

        tarPos = target.transform.position + new Vector3(offsetPos.x, offsetPos.y, 0f);
        Vector3 lookAtSame = Camera.main.transform.TransformDirection(tarPos - from.transform.position);

        if (hpSlider.value <= 0f || lookAtSame.z >= 0f)
        {
            hpSlider.gameObject.SetActive(false);
        }
        else
        {
            hpSlider.gameObject.SetActive(true);
        }

        Vector2 pos = RectTransformUtility.WorldToScreenPoint(Camera.main, tarPos);

        hpSlider.transform.position = pos;
    }
Ejemplo n.º 3
0
    // Update is called once per frame
    void Update()
    {
        tankHealth targetHealth = target.GetComponent <tankHealth>();

        if (!targetHealth)
        {
            return;
        }
        hpSlider.value = targetHealth.HPpercent();
    }