public void StrafeCycle(BehaviourAI ai, SenseMemoryFactory.SMData data) { // get target ai.playerTarget = data.targets[0]; // get destination Vector3 moveTarget = ai.transform.position + Random.insideUnitSphere * strafeLength; // choose closer strafe target each time while (Vector3.Distance(moveTarget, data.targets[0].position) > Vector3.Distance(ai.transform.position, data.targets[0].position)) { moveTarget = ai.transform.position + Random.insideUnitSphere * strafeLength; Debug.Log("strafeMoveTargetChanged"); } // set destination.y moveTarget.y = moveHeight; // start height lerp method ai.HoverHeight(moveTarget.y); //Debug.Log("Strafing"); //GameObject sphere = GameObject.CreatePrimitive(PrimitiveType.Sphere); //sphere.transform.position = moveTarget; //sphere.transform.localScale = new Vector3(0.1f, 0.1f, 0.1f); ai.agent.SetDestination(moveTarget); // shoot ai.ShootAt(data.targets[0]); }
void CoverShootCycle(BehaviourAI ai, SenseMemoryFactory.SMData data) { Transform enemyTarget = data.targets[0]; // get cover point coverPoint = ai.GetAvoidanceWaypoint(data.targets[0].position); // move to cover point ai.agent.SetDestination(coverPoint); // fire while moving ai.ShootAt(enemyTarget); }
public override void StartPatternWith(BehaviourAI ai, SenseMemoryFactory.SMData data) { base.StartPatternWith(ai, data); // closest target (FoV script orders targets in list) Transform target = data.targets[0]; // Go toward player target ai.agent.SetDestination(target.position); if (ai.isGuard) { if (ai.hand) { ai.hand.LookAt(target.position); } else { Debug.Log("You need to asign the AI Hand Transform component to aim the gun"); } } // fire ai.ShootAt(target); }