Пример #1
0
        // Use this for initialization
        void Awake()
        {
            //initialize various values.
            //Mainly taking inputs from the user and putting them into the formats we use later,
            //eg: squared values for faster distance comparison.
            myTransform = transform;

            timeUntilNextDodge         = timeBetweenLoSDodges * Random.value;
            dodgeClearHeightCheckPos   = Vector3.zero;
            dodgeClearHeightCheckPos.y = dodgingClearHeight;

            distFromTargetToSprint = distFromTargetToSprint * distFromTargetToSprint;
            meleeRange             = meleeRange * meleeRange;

            if (navmeshInterfaceClass == null)
            {
                navI = (TacticalAI.NavmeshInterface)gameObject.AddComponent(typeof(TacticalAI.NavmeshInterface));
                navI.Initialize(gameObject);
            }
            else
            {
                navI = navmeshInterfaceClass;
                navI.Initialize(gameObject);
            }
            //else
            //{
            //	navI = (navmeshInterfaceClass)gameObject.AddComponent(typeof(navmeshInterfaceClass));
            //	navI.Initialize(gameObject);
            //}

            /*if(gameObject.GetComponent<NavMeshAgent>() != null){
             *  agent = gameObject.GetComponent<NavMeshAgent>();
             *  origAcceleration = navI.GetAcceleration;
             *  navI.SetSpeed(idleSpeed);
             *  origAgentStoppingDist = navI.GetStoppingDistance();
             * }
             * else{
             *  Debug.LogWarning("No navmesh agent on the same object as the BaseScript!  Please add one!");
             *  this.enabled = false;
             *  return;
             * }*/



            if (idleSpeed > runSpeed)
            {
                idleSpeed = runSpeed;
            }
            if (headLookScript)
            {
                headLookScript.Deactivate();
            }
        }
Пример #2
0
        void Start()
        {
            //Set offset of mesh
            if (myAIBodyTransform)
            {
                bodyOffset               = myAIBodyTransform.localPosition;
                bodyOffset.x            *= transform.localScale.x;
                bodyOffset.y            *= transform.localScale.y;
                bodyOffset.z            *= transform.localScale.z;
                myAIBodyTransform.parent = null;
            }
            else
            {
                Debug.LogWarning("No transform set for 'myAIBodyTransform'.  Please assign a transform in the inspector!");
                this.enabled = false;
            }

            //Inititate Hashes and stuff
            navi            = myBaseScript.GetAgent();
            minDistToCrouch = minDistToCrouch * minDistToCrouch;
            myTransform     = transform;

            lerpSpeed = myBaseScript.runSpeed;


            //Check to make sure we have all of our scripts assigned
            if (!myBaseScript)
            {
                Debug.LogWarning("No Base Script found!  Please add one in the inspector!");
                this.enabled = false;
            }
            else if (maxMovementSpeed < 0)
            {
                maxMovementSpeed = myBaseScript.runSpeed;
            }

            if (!animator)
            {
                Debug.LogWarning("No animator component found!  Please add one in the inspector!");
                this.enabled = false;
            }
            else
            {
                animator.speed = animatorSpeed;
            }
        }
Пример #3
0
        public virtual void Initiate()
        {
            if (gameObject.GetComponent <TacticalAI.BaseScript>())
            {
                baseScript = gameObject.GetComponent <TacticalAI.BaseScript>();

                gunScript            = baseScript.gunScript;
                soundScript          = baseScript.audioScript;
                rotateToAimGunScript = baseScript.headLookScript;
                animationScript      = baseScript.animationScript;
                coverFinderScript    = baseScript.coverFinderScript;
                myTransform          = baseScript.GetTranform();

                layerMask = TacticalAI.ControllerScript.currentController.GetLayerMask();

                navI = baseScript.GetAgent();
            }
        }