Exemple #1
0
        private void ChaseTarget(ShipStateController controller)
        {
            ShipMotor shipMotor = controller.GetMotor();
            Rigidbody ship      = controller.GetRigidbody();
            Rigidbody target    = controller.GetTarget();

            if (target == null)
            {
                return;
            }

            Steer(shipMotor, ship, target);

            AdjustThrottle();

            Vector3 toTarget = target.position - ship.position;

            float angle = Vector3.Angle(ship.transform.forward, toTarget);



            Vector3 velocityDifference = ship.velocity - target.velocity;

            //Check throttle
            //Check angle from player
            //Check velocity differences
            //Adjust throttle

            //steer based on stats/throttle
        }
Exemple #2
0
        void Fire(ShipStateController controller)
        {
            float timeInState = controller.GetTimeInCurrentState();

            if (timeInState > attackDelay)
            {
                Rigidbody shipRigidbody = controller.GetRigidbody();
                Ray       forward       = new Ray(shipRigidbody.position, shipRigidbody.transform.forward);

                controller.GetWeaponSystem().Fire(forward, controller.GetTarget());
            }
        }
Exemple #3
0
        bool ValidatePosition(ShipStateController controller, Rigidbody target)
        {
            Rigidbody myself = controller.GetRigidbody();

            //False if too far away
            if (Vector3.Distance(myself.position, target.position) > maxRange)
            {
                return(false);
            }

            //False if we aren't facing near the target
            Vector3 towards = target.position - myself.position;

            if (Vector3.Angle(myself.transform.forward, towards) > maxAngle)
            {
                return(false);
            }

            return(true);
        }