示例#1
0
 void Start()
 {
     if (aimRate <= 0)
     {
         aimRate = 0.3f;
     }
     if (!overrideSprint)
     {
         //Get sprint info form MovementValues
         sprintDuration = MovementValues.singleton.sprintDuration;
         sprintAddStand = MovementValues.singleton.sprintAddStand;
         sprintAddWalk  = MovementValues.singleton.sprintAddWalk;
         sprintMin      = MovementValues.singleton.sprintMin;
         recoverDelay   = MovementValues.singleton.recoverDelay;
         exhaustedDelay = MovementValues.singleton.exhaustedDelay;
     }
     AimPrimary();
     cmra       = PlayerWeapons.mainCam;
     wcmra      = PlayerWeapons.weaponCam;
     player     = PlayerWeapons.player;
     sprintNum  = sprintDuration;
     canSprint  = true;
     aiming     = false;
     sprinting  = false;
     controller = player.GetComponent <CharacterController>();
     if (zoomFactor == 0)
     {
         zoomFactor = 1;
     }
     AspectCheck();
     CM = GameObject.FindWithTag("Player").GetComponent <CharacterMotorDB>();
 }
示例#2
0
        void Awake()
        {
            if (PW)
            {
                Debug.LogError("Too many instances of PlayerWeapons! There should only be one per scene");
            }
            PW         = this;
            weaponCam  = GameObject.FindWithTag("WeaponCamera");
            mainCam    = GameObject.FindWithTag("MainCamera");
            player     = GameObject.FindWithTag("Player");
            CM         = player.GetComponent <CharacterMotorDB>();
            controller = player.GetComponent <CharacterController>();
            hidden     = false;

            SetSensitivity();
        }
示例#3
0
        void Start()
        {
            idle          = false;
            CM            = PlayerWeapons.CM;
            stopAnimTime  = 10;
            aim           = false;
            nullAnimation = nullAnim;

            /*foreach( AnimationState s   in animation) {
             *      s.layer = 1;
             * }*/

            if (GetComponent <Animation>()[nullAnim] != null)
            {
                GetComponent <Animation>()[nullAnim].layer   = -2;
                GetComponent <Animation>()[nullAnim].enabled = true;
            }
            if (GetComponent <Animation>()[walkAnimation] != null)
            {
                GetComponent <Animation>()[walkAnimation].layer   = -1;
                GetComponent <Animation>()[walkAnimation].enabled = true;
            }

            /*	if(animation[strafeRightAnimation] != null){
             *              animation[strafeRightAnimation].layer = -1;
             *              animation[strafeRightAnimation].enabled = true;
             *      } else {
             *              useStrafe = false;
             *      }*/

            if (GetComponent <Animation>()[sprintAnim] != null)
            {
                GetComponent <Animation>()[sprintAnim].layer = -1;
            }

            GetComponent <Animation>().SyncLayer(-1);

            stopAnimTime = -1;
        }
 // Use this for initialization
 void Awake()
 {
     motor = GetComponent <CharacterMotorDB>();
 }
示例#5
0
 void Awake()
 {
     effectsManager = GameObject.FindObjectOfType <EffectsManager>();
     characterMotor = gameObject.GetComponent <CharacterMotorDB>();
     source         = gameObject.GetComponent <AudioSource>();
 }
示例#6
0
 void Start()
 {
     CM           = GameObject.FindWithTag("Player").GetComponent <CharacterMotorDB>();
     targetHeight = 0;
 }
示例#7
0
        void Update()
        {
            if (gs != null)
            {
                if (!gs.gunActive)
                {
                    return;
                }
            }
            if (GetComponent <Animation>()[nullAnim] == null)
            {
                return;
            }
            if (GetComponent <Animation>()[walkAnimation] == null)
            {
                return;
            }

            CharacterMotorDB CM = PlayerWeapons.CM;

            if (!CM.grounded)
            {
                nullWeight = Mathf.Lerp(nullWeight, 1, Time.deltaTime * 5);
                moveWeight = 0;
            }
            if (Time.time > stopAnimTime + .1)
            {
                moveWeight = Mathf.Lerp(moveWeight, 1, Time.deltaTime * 5);
                nullWeight = Mathf.Lerp(nullWeight, 1, Time.deltaTime * 5);
            }
            else
            {
                moveWeight = 0;
                nullWeight = 0;
            }

            GetComponent <Animation>()[nullAnim].weight = nullWeight;

            Vector3   veloc = PlayerWeapons.CM.movement.velocity;
            Transform trans = PlayerWeapons.player.transform;

            dir = Vector3.Lerp(dir, trans.InverseTransformDirection(veloc), Time.deltaTime * 6);
            Vector3 dirN = dir.normalized;

            float forwardWeight = dirN.z;
            float rightWeight   = dirN.x;

            //Weight and speed from direction
            GetComponent <Animation>()[walkAnimation].weight = Mathf.Abs(forwardWeight) * moveWeight;
            GetComponent <Animation>()[walkAnimation].speed  = dir.z / CM.movement.maxForwardSpeed;

            float strafeWeight = Mathf.Abs(rightWeight) * moveWeight;
            float strafeSpeed  = dir.x / CM.movement.maxSidewaysSpeed * moveWeight;

            //Apply to strafe animation

            /* if(useStrafe){
             *       animation[strafeRightAnimation].weight = strafeWeight;
             *       animation[strafeRightAnimation].speed = strafeSpeed;
             * } else {*/
            //Handle if we don't have a strafe animation by applying to walk animation
            GetComponent <Animation>()[walkAnimation].weight = Mathf.Max(GetComponent <Animation>()[walkAnimation].weight, strafeWeight);
            if (Mathf.Abs(strafeSpeed) > Mathf.Abs(GetComponent <Animation>()[walkAnimation].speed))
            {
                GetComponent <Animation>()[walkAnimation].speed = strafeSpeed;
            }
            //  }
        }
示例#8
0
 void Start()
 {
     CM     = PlayerWeapons.CM;
     values = MovementValues.singleton;
 }
示例#9
0
        public void WalkSway()
        {
            if (swayStartTime > Time.time)
            {
                swayStartTime = Time.time;
            }
            CharacterMotorDB CM = PlayerWeapons.CM;
            int speed           = (int)CM.GetComponent <CharacterController>().velocity.magnitude;

            //Jostle
            lastJostle = curJostle;
            curJostle  = Vector3.Lerp(curJostle, jostleAmt, Time.deltaTime * 16);
            jostleAmt  = Vector3.Lerp(jostleAmt, Vector3.zero, Time.deltaTime * 4);
            transform.localPosition += (curJostle - lastJostle) * 15;

            if (speed < .2)
            {
                ResetPosition();
                return;
            }
            //sine function for motion
            float   t = Time.time - swayStartTime;
            Vector3 curVect;

            swayAmplitude = moveSwayAmplitude;
            if (CharacterMotorDB.crouching)
            {
                swayRate = moveSwayRate * CM.movement.maxCrouchSpeed / CM.movement.defaultForwardSpeed;
            }
            else if (CharacterMotorDB.prone)
            {
                swayRate = moveSwayRate * CM.movement.maxProneSpeed / CM.movement.defaultForwardSpeed;
            }
            else if (AimMode.sprintingPublic)
            {
                swayRate      = runSwayRate;
                swayAmplitude = runSwayAmplitude;
            }
            else
            {
                swayRate = moveSwayRate;
            }
            curVect.x = swayAmplitude.x * Mathf.Sin(swayRate.x * t);             //*Mathf.Sin(swayRate.x*speed/14*t);
            curVect.y = Mathf.Abs(swayAmplitude.y * Mathf.Sin(swayRate.y * t));

            curVect.x -= swayAmplitude.x / 2;
            curVect.y -= swayAmplitude.y / 2;

            Vector3 eulerAngles = transform.localEulerAngles;

            //Move
            lastVal       = val;
            val.x         = Mathf.Lerp(val.x, curVect.x, Time.deltaTime * swayRate.x);
            eulerAngles.z = Mathf.LerpAngle(eulerAngles.z, -curVect.x * .5f, Time.deltaTime * swayRate.x);

            val.y         = Mathf.Lerp(val.y, curVect.y, Time.deltaTime * swayRate.y);
            eulerAngles.x = Mathf.LerpAngle(eulerAngles.x, -curVect.y * .5f, Time.deltaTime * swayRate.y);
            //transform.localPosition.x = Vector3.Lerp(transform.localPosition.x, curVect.x, Time.deltaTime*swayRate.x);

            transform.localEulerAngles = eulerAngles;

            Vector3 localPos = transform.localPosition;

            localPos.x += val.x - lastVal.x;
            localPos.y += val.y - lastVal.y;

            transform.localPosition = localPos;
        }