void Start () { fRWheel = transform.FindChild("FR_Phys_Wheel").GetComponent<WheelController>(); fLWheel = transform.FindChild("FL_Phys_Wheel").GetComponent<WheelController>(); bRWheel = transform.FindChild("RR_Phys_Wheel").GetComponent<WheelController>(); bLWheel = transform.FindChild("RL_Phys_Wheel").GetComponent<WheelController>(); massCenterPosition = transform.FindChild("Mass_Center").localPosition; rb = GetComponent<Rigidbody>(); currentGear = 0; gearRatio = gearRatios[currentGear]; engineRpm = minRpm; centerToFrontWheels = GameObject.Find("F_Axel").GetComponent<Transform>().localPosition.z - massCenterPosition.z; centerToBackWheels = massCenterPosition.z - GameObject.Find("R_Axel").GetComponent<Transform>().localPosition.z; frontToBackWheels = centerToBackWheels + centerToFrontWheels; centerToLeftWheels = massCenterPosition.x - GameObject.Find("FL_Wheel").GetComponent<Transform>().localPosition.x; centerToRightWheels = GameObject.Find("FR_Wheel").GetComponent<Transform>().localPosition.x - massCenterPosition.x; leftToRightWheels = centerToRightWheels + centerToLeftWheels; velocity = new Vector3(); prevVelocity = velocity; aiController = GetComponent<AIInputController> (); }
public static void BackpedalBehavior(AIInputController controller) { if (controller.Target != null) { controller.transform.rotation = Quaternion.Lerp(controller.transform.rotation, Quaternion.LookRotation(controller.Unit.DirectionToTarget), controller.Unit.angleInterpolationFactor * Time.fixedDeltaTime); if (controller.TargetDistance < controller.attackDistance) { if (controller.Sensor.GotVisual) { controller.WeaponManager.Primary(0); if (controller.WeaponManager.OffHandWeapon != null) { controller.WeaponManager.Primary(1); } controller.WeaponManager.EndPrimary(0); if (controller.WeaponManager.OffHandWeapon != null) { controller.WeaponManager.EndPrimary(1); } } } controller.Unit.ForwardInput = Mathf.Lerp(controller.Unit.ForwardInput, -1.0f, 2.0f * Time.deltaTime); } }
public StateMachine(AIInputController _script, List <State> _states) { // Got a problem here if _states.length == 0... states = _states; currentState = initialState = states[0]; script = _script; }
public override void GetAction(AIInputController script) { script.steering += Seek.GetSteering(script.target._static.position, script.self._static.position, script.tank.maxSpeed).Weight(1.0f); if (script.CheckShieldDanger()) { transitions[0].bTriggered = true; } }
public static void GetInRangeAndAttackBehavior(AIInputController controller) { if (controller.Target != null && controller.Unit.Path != null && controller.Unit.Path.Length != 0) { Vector3 dir; if (controller.TargetDistance <= controller.attackDistance && controller.Sensor.GotVisual) { dir = (controller.Target.transform.position - controller.transform.position).normalized; dir.y = 0.0f; } else { dir = controller.Unit.DirectionToNextPoint; } if (dir != Vector3.zero) { controller.transform.rotation = Quaternion.Lerp(controller.transform.rotation, Quaternion.LookRotation(dir), controller.Unit.angleInterpolationFactor * Time.fixedDeltaTime); } if (controller.TargetDistance > controller.attackDistance || !controller.Sensor.GotVisual) { controller.Unit.ForwardInput = Mathf.Lerp(controller.Unit.ForwardInput, 1.0f, 1.0f * Time.deltaTime); } else { if (controller.Sensor.GotVisual) { controller.WeaponManager.Primary(0); if (controller.WeaponManager.OffHandWeapon != null) { controller.WeaponManager.Primary(1); } controller.WeaponManager.EndPrimary(0); if (controller.WeaponManager.OffHandWeapon != null) { controller.WeaponManager.EndPrimary(1); } } controller.Unit.ForwardInput = Mathf.Lerp(controller.Unit.ForwardInput, 0.0f, 3.0f * Time.deltaTime); } } else { controller.Unit.ForwardInput = Mathf.Lerp(controller.Unit.ForwardInput, 0.0f, 3.0f * Time.deltaTime); } }
void UpdateAIForTeam(Team team) { List <GameObject> list = GetPlayersInTeam(team); int count = 0; foreach (GameObject obj in list) { CharacterController controller = obj.GetComponent <CharacterController>(); AIInputController ai = controller as AIInputController; if (ai) { ai.AIDifficulty = GameDifficulty; ai.Defensive = (count == 0); count++; } } }
public static void FleeBehavior(AIInputController controller) { }
void Start () { currentState = aiStates.OBSTACLE_AVOID; laneSystem = GameObject.FindGameObjectWithTag ("LaneSystem").GetComponent<LaneSystem> (); turnLeft = turnRight = false; goForward = true; rb = GetComponent<Rigidbody> (); // InputController.Instance.SetAI (true); aiController = GetComponent<AIInputController> (); prevPosition = transform.position; laneManager = GetComponent<AILaneManager> (); offTrack = false; }
public void GetAction(AIInputController script) { bTriggered = false; }
public virtual void GetExitAction(AIInputController script) { }