using System.Collections; using System.Collections.Generic; using UnityEngine; public class EnemyShoot : MonoBehaviour { public Transform rifle; public Transform player; public float distance; // Start is called before the first frame update void Start() { } // Update is called once per frame void Update() { transform.LookAt(player); } private void Shoot() { RaycastHit hit; PlayerHealth playerHealth; if(Physics.Raycast(transform.position, transform.forward, out hit, distance)) { if(hit.transform.tag == "Player") { playerHealth = hit.transform.GetComponent<PlayerHealth>(); playerHealth.TakeDamage(); Debug.Log(playerHealth.health); } } } }
TakeDamage
protected
private
Shoot
public
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)