public virtual int[] Reload(int[] ammo) { if (CurAmmo < MaxAmmo && curAnim == weaponAnimType.None) { if (ammo[(int)ammoType] != 0) { lastReloadStart = Time.time; curAnim = weaponAnimType.Reloading; //Debug.Log ("Out of bullets!"); ammo[(int)ammoType] += CurAmmo; CurAmmo = 0; if (ammo[(int)ammoType] >= MaxAmmo) { CurAmmo = MaxAmmo; ammo[(int)ammoType] -= MaxAmmo; } else { CurAmmo = ammo[(int)ammoType]; ammo[(int)ammoType] = 0; } } } return(ammo); //~!~!~!~!~!~!~! }
public int[] Reload(int[] ammo) { if (CurAmmo < MaxAmmo && !isFiring && curAnim == weaponAnimType.None) { AnimClock = 15; curAnim = weaponAnimType.Reloading; if (ammo[(int)ammoType] == 0) { Debug.Log("Out of bullets!"); } ammo[(int)ammoType] += CurAmmo; CurAmmo = 0; if (ammo[(int)ammoType] >= MaxAmmo) { CurAmmo = MaxAmmo; ammo[(int)ammoType] -= MaxAmmo; } else { CurAmmo = ammo[(int)ammoType]; ammo[(int)ammoType] = 0; } } return(ammo); //~!~!~!~!~!~!~! }
public virtual void stow() { curAnim = weaponAnimType.Stowing; isAimed = false; isOut = false; lastHoldToggle = Time.time; }
public virtual void withdraw() { curAnim = weaponAnimType.Withdrawing; isAimed = false; isOut = true; lastHoldToggle = Time.time; }
/// <summary> /// Shoots the gun from an AI, instead of a player. /// </summary> /// <returns> /// Wether the gun shot. /// </returns> /// <param name='camera'> /// The GameObject that is situated in place of a camera. /// </param> public virtual bool AIShoot(GameObject camera, Enemy shooter) { //Debug.Log("Attempting firing"); if (CurAmmo > 0 && actionHasReset() && curAnim == weaponAnimType.None) { //Debug.Log("Firing by AI"); CurAmmo -= 1; ((AudioSource)mainObject.GetComponent <AudioSource>()).Play(); //Debug.Log("Setting anim clock to " + ((int)(30/(7.5*FireRateAsPercent / 100))) + // ", or " + (30/(7.5*FireRateAsPercent / 100))); //Debug.Log("Acheived via (30/(7.5*(" + FireRateAsPercent + "/100)))" ); //Debug.Log("Acheived via " + 30/(7.5*FireRateAsPercent/100)); isFiring = true; curAnim = weaponAnimType.Firing; camera.transform.parent.Rotate(0, Random.Range(-maxRecoilSway, maxRecoilSway), 0); if (SmokePuff) { GameObject Thing = (GameObject)MonoBehaviour.Instantiate(SmokePuff, new Vector3(0, 0, 0), mainObject.transform.rotation); Thing.transform.parent = mainObject.transform; Thing.transform.localPosition = SmokePuffPosition; //Thing.transform.Rotate(rot, Space.Self); } PathfindingEnemy.hearNoise(shooter, actualDetectionDistance); for (int i = 0; i < numOfShots; i++) { /* * Vector3 aim = camera.transform.forward; * //aim.Set (aim.x+Random.Range(-xSpread/10,xSpread/10), aim.y+Random.Range(-yspread/10,yspread/10), 0); */ Vector2 position = Random.insideUnitCircle; float x = position.x * xSpread; float y = position.y * yspread; // This defines a point half a meter in front of the shooter, bypassing all sorts of detection issues. Ray ray = new Ray(camera.transform.TransformPoint(Vector3.forward * 0.26f), camera.transform.forward.RotateX(x * Mathf.Deg2Rad).RotateY(y * Mathf.Deg2Rad)); RaycastHit hit; if (Physics.Raycast(ray, out hit, Range)) { generateHit(hit, shooter).calculateDamage(); } } lastShot = Time.time; return(true); } return(false); }
/// <summary> /// Shoot this gun. /// </summary> /// <param name='camera'> /// Camera to aim from. /// </param> public virtual bool Shoot(Camera cCamera, Enemy shooter) { if (CurAmmo > 0/*TODO Modify: && !vehicle.riding*/ && actionHasReset() && curAnim == weaponAnimType.None){ CurAmmo -= 1; mainObject.GetComponent<AudioSource>().Play(); PathfindingEnemy.hearNoise(shooter, actualDetectionDistance); //Debug.Log("Setting anim clock to " + ((int)(30/(7.5*FireRateAsPercent / 100))) + // ", or " + (30/(7.5*FireRateAsPercent / 100))); //Debug.Log("Acheived via (30/(7.5*(" + FireRateAsPercent + "/100)))" ); //Debug.Log("Acheived via " + 30/(7.5*FireRateAsPercent/100)); isFiring = true; curAnim = weaponAnimType.Firing; if (SmokePuff) { GameObject Thing = (GameObject)MonoBehaviour.Instantiate(SmokePuff, new Vector3 (0,0,0), mainObject.transform.rotation); Thing.transform.parent = mainObject.transform; Thing.transform.localPosition = SmokePuffPosition; //Thing.transform.Rotate(rot, Space.Self); } for (int i = 0; i<numOfShots; i++) { Vector2 position = Random.insideUnitCircle; float x = position.x * xSpread; float y = position.y * yspread; // This defines a point half a meter in front of the shooter, bypassing all sorts of detection issues. Ray ray = new Ray(camera.transform.TransformPoint(Vector3.forward * 0.26f), camera.transform.forward.RotateX(x*Mathf.Deg2Rad).RotateY(y*Mathf.Deg2Rad)); RaycastHit hit; if (Physics.Raycast(ray, out hit, Range)){ generateHit(hit, shooter).calculateDamage(); } } camera.transform.parent.Rotate(0,Random.Range(-maxRecoilSway, maxRecoilSway),0); lastShot = Time.time; return true; } return false; }
public virtual int[] Reload(int[] ammo) { if (CurAmmo < MaxAmmo && curAnim == weaponAnimType.None){ if (ammo[(int)ammoType] != 0) { lastReloadStart = Time.time; curAnim = weaponAnimType.Reloading; //Debug.Log ("Out of bullets!"); ammo[(int)ammoType] += CurAmmo; CurAmmo = 0; if (ammo[(int)ammoType] >= MaxAmmo) { CurAmmo = MaxAmmo; ammo[(int)ammoType] -= MaxAmmo; } else { CurAmmo = ammo[(int)ammoType]; ammo[(int)ammoType] = 0; } } } return ammo; //~!~!~!~!~!~!~! }
/// <summary> /// Update animations. /// </summary> public virtual void AnimUpdate() { if (!Exists){ return; } switch (curAnim) { case weaponAnimType.Stowing : mainObject.transform.parent = camera.transform.parent; //mainObject.transform.localPosition = new Vector3( // Mathf.Lerp(mainObject.transform.localPosition.x, StowedPosition.x, (Time.time - lastHoldToggle)/switchSpeed), // Mathf.Lerp(mainObject.transform.localPosition.y, StowedPosition.y, (Time.time - lastHoldToggle)/switchSpeed), // Mathf.Lerp(mainObject.transform.localPosition.z, StowedPosition.z, (Time.time - lastHoldToggle)/switchSpeed)); mainObject.transform.localPosition = //Vector3.Lerp(mainObject.transform.localPosition, StowedPosition, (Time.time - lastHoldToggle)/switchSpeed); Vector3.Lerp(mainObject.transform.localPosition, StowedPosition, (Time.time - lastHoldToggle)/switchSpeed); mainObject.transform.localEulerAngles = Vector3.Slerp(new Vector3(0,0,0), mainObject.transform.localEulerAngles, (Time.time - lastHoldToggle)/switchSpeed); if (mainObject.transform.localPosition.Equals(StowedPosition)) { curAnim = weaponAnimType.None; Debug.Log ("Done moving to Stow position, setting curAnim to 'None'"); } break; case weaponAnimType.Withdrawing : mainObject.transform.parent = camera.transform; //mainObject.transform.localPosition = new Vector3( // Mathf.Lerp(mainObject.transform.localPosition.x, Position.x, (Time.time - lastHoldToggle)/switchSpeed), // Mathf.Lerp(mainObject.transform.localPosition.y, Position.y, (Time.time - lastHoldToggle)/switchSpeed), // Mathf.Lerp(mainObject.transform.localPosition.z, Position.z, (Time.time - lastHoldToggle)/switchSpeed)); //mainObject.transform.localEulerAngles = new Vector3( //Mathf.Lerp(mainObject.transform.localEulerAngles.x, 0, (Time.time - lastHoldToggle)/switchSpeed), //Mathf.Lerp(mainObject.transform.localEulerAngles.y, 0, (Time.time - lastHoldToggle)/switchSpeed), //Mathf.Lerp(mainObject.transform.localEulerAngles.z, 0, (Time.time - lastHoldToggle)/switchSpeed)); mainObject.transform.localEulerAngles = Vector3.Slerp(mainObject.transform.localEulerAngles, new Vector3(0,0,0), (Time.time - lastHoldToggle)/switchSpeed); mainObject.transform.localPosition = Vector3.Lerp(mainObject.transform.localPosition, Position, (Time.time - lastHoldToggle)/switchSpeed); if (mainObject.transform.localPosition.Equals(Position)) { curAnim = weaponAnimType.None; if (debug) Debug.Log ("Done moving to hold position, setting curAnim to 'None'"); } break; case weaponAnimType.None : if (Slide != null) Slide.localPosition.Set(AnimSlideTX.Evaluate(0), AnimSlideTY.Evaluate(0), AnimSlideTZ.Evaluate(0)); if (isOut) { if(isAimed == true){ if (player) camera.GetComponent<Camera>().fieldOfView = Mathf.Lerp(camera.GetComponent<Camera>().fieldOfView, ScopeZoom,Time.deltaTime*zoomSmoothing); mainObject.transform.localPosition = new Vector3( Mathf.Lerp(mainObject.transform.localPosition.x, ScopedPosition.x, (Time.time-lastAim)*AimSpeed), Mathf.Lerp(mainObject.transform.localPosition.y, ScopedPosition.y, (Time.time-lastAim)*AimSpeed), Mathf.Lerp(mainObject.transform.localPosition.z, ScopedPosition.z, (Time.time-lastAim)*AimSpeed)); } else { if (player) camera.GetComponent<Camera>().fieldOfView = Mathf.Lerp(camera.GetComponent<Camera>().fieldOfView, NormalZoom,Time.deltaTime*zoomSmoothing); mainObject.transform.localPosition = new Vector3( Mathf.Lerp(mainObject.transform.localPosition.x, Position.x, (Time.time-lastAim)*AimSpeed), Mathf.Lerp(mainObject.transform.localPosition.y, Position.y, (Time.time-lastAim)*AimSpeed), Mathf.Lerp(mainObject.transform.localPosition.z, Position.z, (Time.time-lastAim)*AimSpeed)); } mainObject.transform.parent = camera.transform; mainObject.transform.localEulerAngles = new Vector3 (0,0,0); } else { mainObject.transform.parent = camera.transform.parent; mainObject.transform.localPosition = StowedPosition; } break; case weaponAnimType.Firing : if (player) { if (Slide == null) { AnimIdentify(); if (Slide == null) { animateSlide = false; } else animateSlide = true; } else animateSlide = true; if (animateSlide) Slide.localPosition = new Vector3 (AnimSlideTX.Evaluate(Time.time - lastShot)*RecoilMult, AnimSlideTY.Evaluate(Time.time - lastShot)*RecoilMult, AnimSlideTZ.Evaluate(Time.time - lastShot)*RecoilMult); mainObject.transform.localPosition = new Vector3 (AnimWeaponTX.Evaluate(Time.time - lastShot)*RecoilMult, AnimWeaponTY.Evaluate(Time.time - lastShot)*RecoilMult, AnimWeaponTZ.Evaluate(Time.time - lastShot)*RecoilMult) + (isAimed ? ScopedPosition : Position); mainObject.transform.localEulerAngles = new Vector3 (AnimWeaponRX.Evaluate(Time.time - lastShot)*RecoilMult, AnimWeaponRY.Evaluate(Time.time - lastShot)*RecoilMult, AnimWeaponRZ.Evaluate(Time.time - lastShot)*RecoilMult); if (player) { mainObject.transform.parent.gameObject.GetComponent<MouseLookModded>().rotationY += (AnimVerticalRecoil.Evaluate(Time.time - lastShot)*RecoilMult - AnimVerticalRecoil.Evaluate(Time.time - lastShot - Time.deltaTime)*RecoilMult); } else { mainObject.transform.parent.Rotate(AnimVerticalRecoil.Evaluate(Time.time - lastShot) - AnimVerticalRecoil.Evaluate(Time.time - lastShot - Time.deltaTime),0,0); } } if (actionHasReset()) { curAnim = weaponAnimType.None; } break; case weaponAnimType.Reloading : if (lastReloadStart + reloadTime < Time.time){ isFiring = false; curAnim = weaponAnimType.None; } break; default : Debug.LogError("INVALID ANIMATIONTYPE? HOW THE F***?"); break; } }
/// <summary> /// Update animations. /// </summary> public void AnimUpdate() { if (!Exists) { return; } if (isAimed == true) { camera.GetComponent <Camera>().fieldOfView = Mathf.Lerp(camera.GetComponent <Camera>().fieldOfView, ScopeZoom, Time.deltaTime * zoomSmoothing); } else { camera.GetComponent <Camera>().fieldOfView = Mathf.Lerp(camera.GetComponent <Camera>().fieldOfView, NormalZoom, Time.deltaTime * zoomSmoothing); } switch (curAnim) { case weaponAnimType.None: break; case weaponAnimType.Firing: //Debug.Log("AnimClock Reads " + AnimClock.ToString()); //Debug.Log("ShotDelay Reads " + ShotDelay.ToString()); //Debug.Log("Animating " + mainObject.name); if (Slide == null || Hammer == null || Trigger == null) { AnimIdentify(); } if (flash == null) { findFlash(); } if (AnimClock == ShotDelay) { Hammer.Rotate(-HammerRotation, 0, 0); mainObject.transform.Translate(0, 0, -gunDistance / 4); mainObject.transform.Rotate(-gunAngle * 0.25f, 0, 0); mainObject.transform.Translate(0, 0, -gunDistance / 4); mainObject.transform.Rotate(-gunAngle * 0.25f, 0, 0); mainObject.transform.Translate(0, 0, -gunDistance / 4); mainObject.transform.Rotate(-gunAngle * 0.25f, 0, 0); mainObject.transform.Translate(0, 0, -gunDistance / 4); mainObject.transform.Rotate(-gunAngle * 0.25f, 0, 0); Slide.Translate(0, 0, SlideDistance); Trigger.Translate(0, 0, TriggerDistance); //flash.transform.localScale = new Vector3 (10,10,10); flash.SetActive(true); ((MouseLookModded)mainObject.transform.parent.gameObject.GetComponent("MouseLookModded")).rotationY += CameraClimb; float x = mainObject.transform.parent.parent.localEulerAngles.x; float y = mainObject.transform.parent.parent.localEulerAngles.y; float z = mainObject.transform.parent.parent.localEulerAngles.z; mainObject.transform.parent.parent.localEulerAngles = new Vector3(x, y + Random.Range(-maxCameraSway, maxCameraSway), z); //+= Random.Range(maxCameraSway, -maxCameraSway) } if (AnimClock == (ShotDelay - 1)) { mainObject.transform.Rotate(gunAngle * 0.25f, 0, 0); mainObject.transform.Translate(0, 0, gunDistance / 4); //flash.transform.localScale = new Vector3 (0,0,0); flash.SetActive(false); ((MouseLookModded)mainObject.transform.parent.gameObject.GetComponent("MouseLookModded")).rotationY -= CameraClimb / 4; } if (AnimClock == (ShotDelay - 2)) { mainObject.transform.Rotate(gunAngle * 0.25f, 0, 0); mainObject.transform.Translate(0, 0, gunDistance / 4); ((MouseLookModded)mainObject.transform.parent.gameObject.GetComponent("MouseLookModded")).rotationY -= CameraClimb / 4; } if (AnimClock == (ShotDelay - 3)) { mainObject.transform.Rotate(gunAngle * 0.25f, 0, 0); mainObject.transform.Translate(0, 0, gunDistance / 4); ((MouseLookModded)mainObject.transform.parent.gameObject.GetComponent("MouseLookModded")).rotationY -= CameraClimb / 4; } if (AnimClock == (ShotDelay - 4)) { mainObject.transform.Rotate(gunAngle * 0.25f, 0, 0); mainObject.transform.Translate(0, 0, gunDistance / 4); Trigger.Translate(0, 0, -TriggerDistance); } if (AnimClock == (ShotDelay - SlideDelay)) { Hammer.Rotate(HammerRotation, 0, 0); Slide.Translate(0, 0, -SlideDistance); } if (AnimClock == 0) { isFiring = false; curAnim = weaponAnimType.None; } if (AnimClock > 0) { AnimClock--; } break; case weaponAnimType.Reloading: if (AnimClock > 0) { AnimClock--; } if (AnimClock == 0) { isFiring = false; curAnim = weaponAnimType.None; } break; default: Debug.LogError("INVALID weaponAnimType! AH!"); break; } }
/// <summary> /// Shoot this gun. /// </summary> /// <param name='camera'> /// Camera to aim from. /// </param> public bool Shoot(Camera camera) { if (CurAmmo > 0 /*TODO Modify: && !vehicle.riding*/ && !isFiring && curAnim == weaponAnimType.None) { CurAmmo -= 1; ((AudioSource)mainObject.GetComponent("AudioSource")).Play(); //Debug.Log("Setting anim clock to " + ((int)(30/(7.5*FireRateAsPercent / 100))) + // ", or " + (30/(7.5*FireRateAsPercent / 100))); //Debug.Log("Acheived via (30/(7.5*(" + FireRateAsPercent + "/100)))" ); //Debug.Log("Acheived via " + 30/(7.5*FireRateAsPercent/100)); AnimClock = (int)(30 / (7.5 * FireRateAsPercent / 100)); ShotDelay = (int)(30 / (7.5 * FireRateAsPercent / 100)); isFiring = true; curAnim = weaponAnimType.Firing; for (int i = 0; i < numOfShots; i++) { Vector2 position = Random.insideUnitCircle; int x = (int)(position.x * xSpread); int y = (int)(position.y * yspread); Ray ray = camera.ScreenPointToRay(new Vector3(Screen.width / 2 + x, Screen.height / 2 + y, 0)); RaycastHit hit; if (Physics.Raycast(ray, out hit, 100)) { Quaternion hitRotation = Quaternion.FromToRotation(Vector3.up, hit.normal); if (hit.transform.gameObject.GetComponent <Rigidbody>() != null) { hit.transform.gameObject.GetComponent <Rigidbody>().AddForce(hit.normal * -HitStrength); } if (hit.transform.tag == "Explosive") { if ((Detonator)hit.transform.gameObject.GetComponent("Detonator") != null) { Detonator target = (Detonator)hit.transform.gameObject.GetComponent("Detonator"); target.Explode(); } if (hit.transform.gameObject.GetComponent("AudioSource") != null) { AudioSource targetSound = (AudioSource)hit.transform.gameObject.GetComponent("AudioSource"); targetSound.Play(); } if (hit.transform.gameObject.GetComponent <ExplosiveDamage>() != null) { hit.transform.gameObject.GetComponent <ExplosiveDamage>().explode(); } } else if (hit.transform.tag == "Enemy") { if (hit.transform.gameObject.GetComponent("AudioSource") != null) { AudioSource targetSound = (AudioSource)hit.transform.gameObject.GetComponent("AudioSource"); targetSound.Play(); } if (hit.transform.gameObject.GetComponent("EnemyHealth") != null) { EnemyHealth enemyHealth = (EnemyHealth)hit.transform.gameObject.GetComponent("EnemyHealth"); enemyHealth.Health -= Damage; MonoBehaviour.print("Dealt " + Damage.ToString() + " Damage to " + hit.transform.gameObject.name); } GameObject newBlood = (GameObject)MonoBehaviour.Instantiate(BloodSpray, hit.point, hitRotation); newBlood.transform.parent = hit.transform; newBlood.transform.Translate(0, (float)0.05, 0); } else { GameObject newBulletHole = (GameObject)MonoBehaviour.Instantiate(BulletHole, hit.point, hitRotation); newBulletHole.transform.parent = hit.transform; newBulletHole.transform.Translate(0, (float)0.05, 0); hitRotation.x = hitRotation.x + 270; GameObject newDust = (GameObject)MonoBehaviour.Instantiate(DirtSpray, hit.point, hitRotation); newDust.transform.parent = hit.transform; newDust.transform.Translate(0, (float)0.05, 0); } } } return(true); } return(false); }
/// <summary> /// Update animations. /// </summary> public virtual void AnimUpdate() { if (!Exists) { return; } switch (curAnim) { case weaponAnimType.Stowing: mainObject.transform.parent = camera.transform.parent; //mainObject.transform.localPosition = new Vector3( // Mathf.Lerp(mainObject.transform.localPosition.x, StowedPosition.x, (Time.time - lastHoldToggle)/switchSpeed), // Mathf.Lerp(mainObject.transform.localPosition.y, StowedPosition.y, (Time.time - lastHoldToggle)/switchSpeed), // Mathf.Lerp(mainObject.transform.localPosition.z, StowedPosition.z, (Time.time - lastHoldToggle)/switchSpeed)); mainObject.transform.localPosition = //Vector3.Lerp(mainObject.transform.localPosition, StowedPosition, (Time.time - lastHoldToggle)/switchSpeed); Vector3.Lerp(mainObject.transform.localPosition, StowedPosition, (Time.time - lastHoldToggle) / switchSpeed); mainObject.transform.localEulerAngles = Vector3.Slerp(new Vector3(0, 0, 0), mainObject.transform.localEulerAngles, (Time.time - lastHoldToggle) / switchSpeed); if (mainObject.transform.localPosition.Equals(StowedPosition)) { curAnim = weaponAnimType.None; Debug.Log("Done moving to Stow position, setting curAnim to 'None'"); } break; case weaponAnimType.Withdrawing: mainObject.transform.parent = camera.transform; //mainObject.transform.localPosition = new Vector3( // Mathf.Lerp(mainObject.transform.localPosition.x, Position.x, (Time.time - lastHoldToggle)/switchSpeed), // Mathf.Lerp(mainObject.transform.localPosition.y, Position.y, (Time.time - lastHoldToggle)/switchSpeed), // Mathf.Lerp(mainObject.transform.localPosition.z, Position.z, (Time.time - lastHoldToggle)/switchSpeed)); //mainObject.transform.localEulerAngles = new Vector3( //Mathf.Lerp(mainObject.transform.localEulerAngles.x, 0, (Time.time - lastHoldToggle)/switchSpeed), //Mathf.Lerp(mainObject.transform.localEulerAngles.y, 0, (Time.time - lastHoldToggle)/switchSpeed), //Mathf.Lerp(mainObject.transform.localEulerAngles.z, 0, (Time.time - lastHoldToggle)/switchSpeed)); mainObject.transform.localEulerAngles = Vector3.Slerp(mainObject.transform.localEulerAngles, new Vector3(0, 0, 0), (Time.time - lastHoldToggle) / switchSpeed); mainObject.transform.localPosition = Vector3.Lerp(mainObject.transform.localPosition, Position, (Time.time - lastHoldToggle) / switchSpeed); if (mainObject.transform.localPosition.Equals(Position)) { curAnim = weaponAnimType.None; if (debug) { Debug.Log("Done moving to hold position, setting curAnim to 'None'"); } } break; case weaponAnimType.None: if (Slide != null) { Slide.localPosition.Set(AnimSlideTX.Evaluate(0), AnimSlideTY.Evaluate(0), AnimSlideTZ.Evaluate(0)); } if (isOut) { if (isAimed == true) { if (player) { camera.GetComponent <Camera>().fieldOfView = Mathf.Lerp(camera.GetComponent <Camera>().fieldOfView, ScopeZoom, Time.deltaTime * zoomSmoothing); } mainObject.transform.localPosition = new Vector3( Mathf.Lerp(mainObject.transform.localPosition.x, ScopedPosition.x, (Time.time - lastAim) * AimSpeed), Mathf.Lerp(mainObject.transform.localPosition.y, ScopedPosition.y, (Time.time - lastAim) * AimSpeed), Mathf.Lerp(mainObject.transform.localPosition.z, ScopedPosition.z, (Time.time - lastAim) * AimSpeed)); } else { if (player) { camera.GetComponent <Camera>().fieldOfView = Mathf.Lerp(camera.GetComponent <Camera>().fieldOfView, NormalZoom, Time.deltaTime * zoomSmoothing); } mainObject.transform.localPosition = new Vector3( Mathf.Lerp(mainObject.transform.localPosition.x, Position.x, (Time.time - lastAim) * AimSpeed), Mathf.Lerp(mainObject.transform.localPosition.y, Position.y, (Time.time - lastAim) * AimSpeed), Mathf.Lerp(mainObject.transform.localPosition.z, Position.z, (Time.time - lastAim) * AimSpeed)); } mainObject.transform.parent = camera.transform; mainObject.transform.localEulerAngles = new Vector3(0, 0, 0); } else { mainObject.transform.parent = camera.transform.parent; mainObject.transform.localPosition = StowedPosition; } break; case weaponAnimType.Firing: if (player) { if (Slide == null) { AnimIdentify(); if (Slide == null) { animateSlide = false; } else { animateSlide = true; } } else { animateSlide = true; } if (animateSlide) { Slide.localPosition = new Vector3(AnimSlideTX.Evaluate(Time.time - lastShot) * RecoilMult, AnimSlideTY.Evaluate(Time.time - lastShot) * RecoilMult, AnimSlideTZ.Evaluate(Time.time - lastShot) * RecoilMult); } mainObject.transform.localPosition = new Vector3(AnimWeaponTX.Evaluate(Time.time - lastShot) * RecoilMult, AnimWeaponTY.Evaluate(Time.time - lastShot) * RecoilMult, AnimWeaponTZ.Evaluate(Time.time - lastShot) * RecoilMult) + (isAimed ? ScopedPosition : Position); mainObject.transform.localEulerAngles = new Vector3(AnimWeaponRX.Evaluate(Time.time - lastShot) * RecoilMult, AnimWeaponRY.Evaluate(Time.time - lastShot) * RecoilMult, AnimWeaponRZ.Evaluate(Time.time - lastShot) * RecoilMult); if (player) { mainObject.transform.parent.gameObject.GetComponent <MouseLookModded>().rotationY += (AnimVerticalRecoil.Evaluate(Time.time - lastShot) * RecoilMult - AnimVerticalRecoil.Evaluate(Time.time - lastShot - Time.deltaTime) * RecoilMult); } else { mainObject.transform.parent.Rotate(AnimVerticalRecoil.Evaluate(Time.time - lastShot) - AnimVerticalRecoil.Evaluate(Time.time - lastShot - Time.deltaTime), 0, 0); } } if (actionHasReset()) { curAnim = weaponAnimType.None; } break; case weaponAnimType.Reloading: if (lastReloadStart + reloadTime < Time.time) { isFiring = false; curAnim = weaponAnimType.None; } break; default: Debug.LogError("INVALID ANIMATIONTYPE? HOW THE F***?"); break; } }