Beispiel #1
0
 // Update is called once per frame
 void Update()
 {
     if (health.GetHealth() == 0)
     {
         Respawn();
     }
     if (gameObject.transform.position.y < -100)
     {
         health.UpdateHealth(-10);
     }
 }
Beispiel #2
0
    void ShootRay()
    {
        Ray        ray = cam.GetComponent <Camera>().ScreenPointToRay(Input.mousePosition);
        RaycastHit hit;

        if (Physics.Raycast(ray, out hit))
        {
            ObjectHealth health = hit.transform.GetComponent <ObjectHealth>();
            if (health != null)
            {
                health.UpdateHealth(-1);
            }
        }
    }