//---------------------------------------------------------------------------------- - // On Nut Grabbed Function //---------------------------------------------------------------------------------- - private void OnNutGrabbed(NutGrabber nutGrabber) { m_movementController.SetSpeed(m_speed * m_slowMod); m_fxSpawner.SpawnEffect(FXType.GrabNut, true); }
void FixedUpdate() { if (GameManager.gameActive) { GetGroundedInfo(); if (!stunned) { if (inputManager.inputType == TypeOfInput.Controller) { if (inputManager.GetAxisX() < -0.3f || inputManager.GetAxisX() > 0.3f) { rigidbody.AddForce(Vector3.right * speed * inputManager.GetAxisX(), ForceMode.Acceleration); } } else if (inputManager.inputType == TypeOfInput.Keyboard) { rigidbody.AddForce(Vector3.right * speed * inputManager.GetAxisX(), ForceMode.Acceleration); } anim.SetFloat("xSpeed", Mathf.Abs(rigidbody.velocity.x)); anim.SetFloat("ySpeed", Mathf.Abs(rigidbody.velocity.y)); if (rigidbody.velocity.x > 5) { moveX = rigidbody.velocity.x * xDrag; } if (rigidbody.velocity.x < 5) { moveX = 0; } rigidbody.velocity = new Vector3(moveX, rigidbody.velocity.y, 0); if (partSys != null) { partSys.emissionRate = Mathf.Abs(rigidbody.velocity.x) * 33; } //Only downboost on down TAP if (!grounded && inputManager.requestCrouchFlick && !downBoostUsed && !superJumpedRecently) { downBoostUsed = true; inputManager.SetRequestCrouchFlick(false); rigidbody.velocity = new Vector3(0, 0, 0); rigidbody.AddForce(new Vector3(0, -30f, 0), ForceMode.Impulse); } else if (inputManager.requestCrouchFlick && grounded) { inputManager.SetRequestCrouchFlick(false); } if (buttStompRequested) { if (!grounded) { //buttstomp inputManager.SetVibration(0.3f, 0.3f); buttStompAttacker.buttStompAttackActive = true; allowNegativeScaling = false; freezeVeloctiy = true; audio.PlayOneShot(AudioLibrary.buttStompSwoosh01_); anim.SetBool("ButtStomping", true); Invoke("DisableButtStomping", 0.9f); rigidbody.velocity = new Vector3(rigidbody.velocity.x, buttStompForce, 0); } buttStompRequested = false; } if (inputManager.requestCrouch) { anim.SetBool("Crouching", true); if (inputManager.requestJump) { inputManager.requestJump = false; if (grounded) { //superjump superJumpedRecently = true; StartCoroutine(DisableSuperJumpedRecently(0.8f)); rigidbody.velocity = new Vector3(rigidbody.velocity.x, superJumpForce, rigidbody.velocity.z); audioPlayer.PlayOneShot(AudioLibrary.jump03_); anim.SetBool("Jumping", true); Invoke("DisableJumpAnim", 0.4f); } } } else if (!inputManager.requestCrouch) { anim.SetBool("Crouching", false); } if (inputManager.requestJump) { if (grounded) { //Only allow a double jump if a regular jump hasnt occured jumped = true; anim.SetBool("Jumping", true); audioPlayer.PlayOneShot(AudioLibrary.jump01_); //This is for the animation system Invoke("DisableJumpAnim", 0.5f); rigidbody.velocity += new Vector3(0, jumpForce, 0); } else if (!grounded && !jumped && !doubleJumped) { doubleJumped = true; audioPlayer.PlayOneShot(AudioLibrary.jump02_); fxSpawner.SpawnEffect(FXType.DoubleJump); Vector3 resetYVelocity = rigidbody.velocity; resetYVelocity.y = doubleJumpForce; rigidbody.velocity = resetYVelocity; } else if (onWall) { onWall = false; doubleJumped = false; rigidbody.velocity = Vector3.zero; } inputManager.requestJump = false; } if (buttStomping) { rigidbody.velocity = new Vector3(rigidbody.velocity.x, buttStompForce, rigidbody.velocity.z); unfreeze = false; buttStomping = false; } //for buttstomping if (freezeVeloctiy) { rigidbody.velocity = Vector3.zero; if (!unfreeze) { Invoke("UnfreezeVelocity", 0.5f); allowNegativeScaling = true; } } } } }