public void Init() { health = 10; animator = GetComponentInChildren <Animator>(); enemyTarget = GetComponent <EnemyTarget>(); enemyTarget.Init(this); rigid = GetComponent <Rigidbody>(); navMeshAgent = GetComponent <NavMeshAgent>(); rigid.isKinematic = true; animHook = animator.GetComponent <AnimatorHook>(); if (animHook == null) { animHook = animator.gameObject.AddComponent <AnimatorHook>(); } animHook.Init(null, this); InitRagdoll(); isParryOn = false; ignoreLayers = ~(1 << 9); }
public EnemyTarget GetEnemy(Vector3 from) { EnemyTarget target = null; //Get the closest enemy to player float minDistance = float.MaxValue; for (int i = 0; i < enemyTargets.Count; i++) { float distance = Vector3.Distance(from, enemyTargets[i].GetTarget().position); if (distance < minDistance) { minDistance = distance; target = enemyTargets[i]; } } return(target); }