// Update is called once per frame void Update() { if (m_LockOn) { distanceToEndPoint = m_EndRushPosition.magnitude - m_DefaultGroundEnemyBehaviour.GetPosition().magnitude; agent.SetDestination(m_EndRushPosition); if (Math.Abs(distanceToEndPoint) < 0.1) { m_LockOn = false; } } else { m_DefaultGroundEnemyBehaviour.MoveTowardsPlayer(transform, agent); if (m_DefaultGroundEnemyBehaviour.GetDistanceToPlayer() > startRushDistance) { return; } m_RushDirection = m_DefaultGroundEnemyBehaviour.transform.forward; m_StartRushPosition = m_DefaultGroundEnemyBehaviour.GetPosition(); m_EndRushPosition = m_StartRushPosition + rushDistance * m_RushDirection; m_LockOn = true; } }
// Update is called once per frame private void Update() { m_DefaultGroundEnemyBehaviour.MoveTowardsPlayer(transform, agent); if (m_DefaultGroundEnemyBehaviour.GetDistanceToPlayer() < 4) { GetComponent <Renderer>().material.color = Color.red; //Explode } }