private void ProcessRaycast() { RaycastHit hit; if (Physics.Raycast(FPCamera.transform.position, FPCamera.transform.forward, out hit, range)) { CreateHitImpact(hit); EnemyHealthVM target = hit.transform.GetComponent <EnemyHealthVM>(); if (target == null) { return; } target.TakeDamage(damage); } else { return; } }
void Start() { navMeshAgent = GetComponent <NavMeshAgent>(); health = GetComponent <EnemyHealthVM>(); target = FindObjectOfType <PlayerHealthVM>().transform; }