Rocket deals damage
This commit is contained in:
@@ -2,6 +2,7 @@ using UnityEngine;
|
||||
|
||||
public class Rocket : MonoBehaviour
|
||||
{
|
||||
public PlayerMovement playerMovement;
|
||||
public GameObject player;
|
||||
public Vector3 TargetPosition;
|
||||
public float playerDistance;
|
||||
@@ -16,6 +17,7 @@ public class Rocket : MonoBehaviour
|
||||
void Start()
|
||||
{
|
||||
player = GameObject.Find("Player");
|
||||
playerMovement = FindObjectOfType<PlayerMovement>();
|
||||
TargetPosition = player.transform.position;
|
||||
}
|
||||
|
||||
@@ -36,4 +38,19 @@ public class Rocket : MonoBehaviour
|
||||
playerDistance = Vector3.Distance(transform.position, player.transform.position);
|
||||
transform.Translate(Vector3.forward * Time.deltaTime * (playerDistance/1.5f+8));
|
||||
}
|
||||
|
||||
public void OnTriggerEnter(Collider other)
|
||||
{
|
||||
if (other.CompareTag("Player"))
|
||||
{
|
||||
Debug.Log("Hit Player");
|
||||
playerMovement.HP -= 2f;
|
||||
}
|
||||
else if (other.CompareTag("Boss")){
|
||||
Debug.Log("Shooting");
|
||||
}
|
||||
else if (other.CompareTag("Ground")){
|
||||
Destroy(this.gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user