void FixedUpdate() { //Jump action Counter += Time.deltaTime; if (!Input.GetButton("A") && Counter < JumpDuration) { Counter = JumpDuration; } //Keep Colliders Rotation to avoid collision Issues if (Counter < 0.2f) { //transform.rotation = Quaternion.FromToRotation(transform.up, InitialNormal) * transform.rotation; } //Add Jump Speed if (Counter < JumpDuration) { Player.isRolling = false; if (Counter < SlopedJumpDuration) { Player.AddVelocity(InitialNormal * (JumpSpeed)); } else { Player.AddVelocity(new Vector3(0, 1, 0) * (JumpSpeed)); } //Extra speed Player.AddVelocity(new Vector3(0, 1, 0) * (jumpSlopeSpeed)); } //Cancel Jump if (Player.rigidbody.velocity.y > 0 && !Input.GetButton("A")) { Vector3 Velocity = new Vector3(Player.rigidbody.velocity.x, Player.rigidbody.velocity.y, Player.rigidbody.velocity.z); Velocity.y = Velocity.y - StopYSpeedOnRelease; Player.rigidbody.velocity = Velocity; } //End Action if (Player.Grounded && Counter > SlopedJumpDuration) { Actions.ChangeAction(0); Actions.Action06.BounceCount = 0; JumpBall.SetActive(false); } }
void FixedUpdate() { //Jump bool getButtonA = GetComponent <PlayerBinput>().JumpButton.Pressed; bool getButtonADown = GetComponent <PlayerBinput>().JumpButton.PressDown; bool getButtonAUp = GetComponent <PlayerBinput>().JumpButton.PressUp; bool getButtonB = GetComponent <PlayerBinput>().BallButton.Pressed; bool getButtonBDown = GetComponent <PlayerBinput>().BallButton.PressDown; bool getButtonBUp = GetComponent <PlayerBinput>().BallButton.PressUp; bool getButtonR1 = GetComponent <PlayerBinput>().RollButton.Pressed; bool getButtonR1Down = GetComponent <PlayerBinput>().RollButton.PressDown; bool getButtonR1Up = GetComponent <PlayerBinput>().RollButton.PressUp; if ((Input.GetButton("A") || getButtonA) && Player.Grounded) { JumpAction.InitialEvents(); Actions.ChangeAction(1); } //Skidding if (Player.b_normalSpeed < -SkiddingStartPoint && Player.Grounded) { Player.isRolling = false; Player.AddVelocity(Player.rigidbody.velocity.normalized * SkiddingIntensity); if (!hasSked && Player.Grounded) { sounds.SkiddingSound(); hasSked = true; } if (Player.SpeedMagnitude < 4) { Player.b_normalSpeed = 0; hasSked = false; } } else { hasSked = false; } //Set Homing attack to true if (Player.Grounded) { Actions.Action02.HomingAvailable = true; } }
void FixedUpdate() { sounds.WindPlay(); if (Player.SpeedMagnitude < 15 && Player.MoveInput == Vector3.zero && Player.Grounded) { Player.b_normalSpeed = 0; Player.rigidbody.velocity *= 0.90f; hasSked = false; } //Skidding if (Player.b_normalSpeed < -SkiddingStartPoint && Player.Grounded) { if (Player.SpeedMagnitude >= -SkiddingIntensity) { Player.AddVelocity(Player.rigidbody.velocity.normalized * SkiddingIntensity * (Player.isRolling ? 0.5f : 1)); } if (!hasSked && Player.Grounded && !Player.isRolling) { sounds.SkiddingSound(); hasSked = true; } if (Player.SpeedMagnitude < 4) { Player.isRolling = false; Player.b_normalSpeed = 0; hasSked = false; } } else { hasSked = false; } //Set Homing attack to true if (Player.Grounded) { if (Actions.Action02 != null) { Actions.Action02.HomingAvailable = true; } if (Actions.Action06.BounceCount > 0) { Actions.Action06.BounceCount = 0; } } }
void FixedUpdate() { //Jump if (Input.GetButton("A") && Player.Grounded) { JumpAction.InitialEvents(); Actions.ChangeAction(1); } //Skidding if (Player.b_normalSpeed < -SkiddingStartPoint && Player.Grounded) { Player.isRolling = false; Player.AddVelocity(Player.rigidbody.velocity.normalized * SkiddingIntensity); if (!hasSked && Player.Grounded) { sounds.SkiddingSound(); hasSked = true; } if (Player.SpeedMagnitude < 4) { Player.b_normalSpeed = 0; hasSked = false; } } else { hasSked = false; } //Set Homing attack to true if (Player.Grounded) { Actions.Action02.HomingAvailable = true; } }
void FixedUpdate() { //Jump bool getButtonA = GetComponent <PlayerBinput>().JumpButton.Pressed; bool getButtonADown = GetComponent <PlayerBinput>().JumpButton.PressDown; bool getButtonAUp = GetComponent <PlayerBinput>().JumpButton.PressUp; bool getButtonB = GetComponent <PlayerBinput>().BallButton.Pressed; bool getButtonBDown = GetComponent <PlayerBinput>().BallButton.PressDown; bool getButtonBUp = GetComponent <PlayerBinput>().BallButton.PressUp; bool getButtonR1 = GetComponent <PlayerBinput>().RollButton.Pressed; bool getButtonR1Down = GetComponent <PlayerBinput>().RollButton.PressDown; bool getButtonR1Up = GetComponent <PlayerBinput>().RollButton.PressUp; //Jump action Counter += Time.deltaTime; if ((!Input.GetButton("A") && !getButtonA) && Counter < JumpDuration) { Counter = JumpDuration; } //Keep Colliders Rotation to avoid collision Issues if (Counter < 0.2f) { //transform.rotation = Quaternion.FromToRotation(transform.up, InitialNormal) * transform.rotation; } //Add Jump Speed if (Counter < JumpDuration) { Player.isRolling = false; if (Counter < SlopedJumpDuration) { Player.AddVelocity(InitialNormal * (JumpSpeed)); } else { Player.AddVelocity(new Vector3(0, 1, 0) * (JumpSpeed)); } //Extra speed Player.AddVelocity(new Vector3(0, 1, 0) * (jumpSlopeSpeed)); } //Cancell Jump if (Player.rigidbody.velocity.y > 0 && (!Input.GetButton("A") && !getButtonA)) { Vector3 Velocity = new Vector3(Player.rigidbody.velocity.x, Player.rigidbody.velocity.y, Player.rigidbody.velocity.z); Velocity.y = Velocity.y - StopYSpeedOnRelease; Player.rigidbody.velocity = Velocity; } //End Action if (Player.Grounded && Counter > SlopedJumpDuration) { Actions.ChangeAction(0); } }
public void OnTriggerEnter(Collider col) { //Speed Pads Collision if (col.tag == "SpeedPad") { Actions.Action01.JumpBall.SetActive(false); if (Actions.Action08 != null) { if (Actions.Action08.DropEffect.isPlaying == true) { Actions.Action08.DropEffect.Stop(); } } if (col.GetComponent <SpeedPadData>() != null) { transform.rotation = Quaternion.identity; //ResetPlayerRotation if (col.GetComponent <SpeedPadData>().LockToDirection) { Player.rigidbody.velocity = Vector3.zero; Player.AddVelocity(col.transform.forward * col.GetComponent <SpeedPadData>().Speed); } else { Player.AddVelocity(col.transform.forward * col.GetComponent <SpeedPadData>().Speed); } if (col.GetComponent <SpeedPadData>().Snap) { transform.position = col.transform.position; } if (col.GetComponent <SpeedPadData>().isDashRing) { Actions.ChangeAction(0); Actions.Action00.CharacterAnimator.SetBool("Grounded", false); Actions.Action00.CharacterAnimator.SetInteger("Action", 0); } if (col.GetComponent <SpeedPadData>().LockControl) { Inp.LockInputForAWhile(col.GetComponent <SpeedPadData>().LockControlTime, true); } if (col.GetComponent <SpeedPadData>().AffectCamera) { Vector3 dir = col.transform.forward; Cam.SetCamera(dir, 2.5f, 20, 5f, 1); col.GetComponent <AudioSource>().Play(); } } } //Rings Collision if (col.tag == "Ring") { Instantiate(RingCollectParticle, col.transform.position, Quaternion.identity); Destroy(col.gameObject); StartCoroutine(IncreaseRing()); } if (col.tag == "MovingRing") { if (col.GetComponent <MovingRing>() != null) { if (col.GetComponent <MovingRing>().colectable) { StartCoroutine(IncreaseRing()); Instantiate(RingCollectParticle, col.transform.position, Quaternion.identity); Destroy(col.gameObject); } } } //Switch if (col.tag == "Switch") { if (col.GetComponent <Switch_Properties> () != null) { col.GetComponent <Switch_Properties> ().Activate(); } } //Hazard if (col.tag == "Hazard") { Actions.Action01.JumpBall.SetActive(false); if (Actions.Action08 != null) { if (Actions.Action08.DropEffect.isPlaying == true) { Actions.Action08.DropEffect.Stop(); } } DamagePlayer(); HedgeCamera.Shakeforce = EnemyDamageShakeAmmount; } //Enemies if (col.tag == "Enemy") { HedgeCamera.Shakeforce = EnemyHitShakeAmmount; //If 1, destroy, if not, take damage. if (Actions.Action == 3) { col.transform.parent.GetComponent <EnemyHealth>().DealDamage(1); updateTargets = true; } if (Actions.Action00.CharacterAnimator.GetInteger("Action") == 1) { //Actions.Action01.JumpBall.enabled = false; if (col.transform.parent.GetComponent <EnemyHealth>() != null) { if (!Player.isRolling) { Vector3 newSpeed = new Vector3(1, 0, 1); if ((Actions.Action == 1 || Actions.Action == 0) && CanHitAgain) { StartCoroutine(ResetTriggerBool()); ////Debug.Log ("AfterJumping"); newSpeed = new Vector3(Player.rigidbody.velocity.x, 0, Player.rigidbody.velocity.z); newSpeed.y = BouncingPower + Mathf.Abs(Player.rigidbody.velocity.y); ////Debug.Log (newSpeed); Player.rigidbody.velocity = newSpeed; } else if ((Actions.Action == 2 || Actions.PreviousAction == 2) && !StopOnHit && CanHitAgain) { StartCoroutine(ResetTriggerBool()); //Debug.Log ("AfterHoming"); //Vector3 Direction = col.transform.position - Player.transform.position; newSpeed = new Vector3(Player.rigidbody.velocity.x * (1 / EnemyHomingStoppingPowerWhenAdditive), HomingBouncingPower, Player.rigidbody.velocity.z * (1 / EnemyHomingStoppingPowerWhenAdditive)); ////Debug.Log (newSpeed); Player.rigidbody.velocity = newSpeed; } else if (StopOnHit) { //Debug.Log ("AfterHomingStop"); newSpeed = new Vector3(0, 0, 0); newSpeed = Vector3.Scale(Player.rigidbody.velocity, newSpeed); newSpeed.y = HomingBouncingPower; Player.rigidbody.velocity = newSpeed; } if (Actions.Action == 6 && CanHitAgain) { StartCoroutine(ResetTriggerBool()); // //Debug.Log ("AfterBouncing"); newSpeed = new Vector3(1, 0, 1); ////Debug.Log ("AfterHoming"); newSpeed = Vector3.Scale(Player.rigidbody.velocity, newSpeed); newSpeed.y = HomingBouncingPower * 2; Player.rigidbody.velocity = newSpeed; Actions.Action01.JumpBall.SetActive(false); if (Actions.Action08 != null) { if (Actions.Action08.DropEffect.isPlaying == true) { Actions.Action08.DropEffect.Stop(); } } } } col.transform.parent.GetComponent <EnemyHealth>().DealDamage(1); updateTargets = true; Actions.Action01.JumpBall.SetActive(false); if (Actions.Action08 != null) { if (Actions.Action08.DropEffect.isPlaying == true) { Actions.Action08.DropEffect.Stop(); } } Actions.ChangeAction(0); } } else if (Actions.Action != 3) { DamagePlayer(); } } //Monitors if (col.tag == "Monitor") { if (Actions.Action00.CharacterAnimator.GetInteger("Action") == 1) { if (!Player.isRolling) { Vector3 newSpeed = new Vector3(1, 0, 1); if ((Actions.Action == 1 || Actions.Action == 0) && CanHitAgain) { StartCoroutine(ResetTriggerBool()); ////Debug.Log ("AfterJumping"); newSpeed = new Vector3(Player.rigidbody.velocity.x, 0, Player.rigidbody.velocity.z); newSpeed.y = BouncingPower + Mathf.Abs(Player.rigidbody.velocity.y); ////Debug.Log (newSpeed); Player.rigidbody.velocity = newSpeed; } else if ((Actions.Action == 2 || Actions.PreviousAction == 2) && !StopOnHit && CanHitAgain) { StartCoroutine(ResetTriggerBool()); //Debug.Log ("AfterHoming"); //Vector3 Direction = col.transform.position - Player.transform.position; newSpeed = new Vector3(Player.rigidbody.velocity.x * (1 / EnemyHomingStoppingPowerWhenAdditive), HomingBouncingPower, Player.rigidbody.velocity.z * (1 / EnemyHomingStoppingPowerWhenAdditive)); ////Debug.Log (newSpeed); Player.rigidbody.velocity = newSpeed; } else if (StopOnHit) { //Debug.Log ("AfterHomingStop"); newSpeed = new Vector3(0, 0, 0); newSpeed = Vector3.Scale(Player.rigidbody.velocity, newSpeed); newSpeed.y = HomingBouncingPower; Player.rigidbody.velocity = newSpeed; } if (Actions.Action == 6 && CanHitAgain) { StartCoroutine(ResetTriggerBool()); // //Debug.Log ("AfterBouncing"); newSpeed = new Vector3(1, 0, 1); ////Debug.Log ("AfterHoming"); newSpeed = Vector3.Scale(Player.rigidbody.velocity, newSpeed); newSpeed.y = HomingBouncingPower * 2; Player.rigidbody.velocity = newSpeed; Actions.Action01.JumpBall.SetActive(false); if (Actions.Action08 != null) { if (Actions.Action08.DropEffect.isPlaying == true) { Actions.Action08.DropEffect.Stop(); } } } } updateTargets = true; Actions.Action01.JumpBall.SetActive(false); if (Actions.Action08 != null) { if (Actions.Action08.DropEffect.isPlaying == true) { Actions.Action08.DropEffect.Stop(); } } Actions.ChangeAction(0); } } //Spring Collision if (col.tag == "Spring") { Actions.Action01.JumpBall.SetActive(false); if (Actions.Action08 != null) { if (Actions.Action08.DropEffect.isPlaying == true) { Actions.Action08.DropEffect.Stop(); } } if (col.GetComponent <Spring_Proprieties>() != null) { spring = col.GetComponent <Spring_Proprieties>(); if (spring.IsAdditive) { transform.position = col.transform.GetChild(0).position; if (col.GetComponent <AudioSource>()) { col.GetComponent <AudioSource>().Play(); } Actions.Action00.CharacterAnimator.SetInteger("Action", 0); if (Actions.Action02 != null) { Actions.Action02.HomingAvailable = true; } Player.rigidbody.velocity += (spring.transform.up * spring.SpringForce); Actions.ChangeAction(0); spring.anim.SetTrigger("Hit"); } else { transform.position = col.transform.GetChild(0).position; if (col.GetComponent <AudioSource>()) { col.GetComponent <AudioSource>().Play(); } Actions.Action00.CharacterAnimator.SetInteger("Action", 0); if (Actions.Action02 != null) { Actions.Action02.HomingAvailable = true; } Player.rigidbody.velocity = spring.transform.up * spring.SpringForce; Actions.ChangeAction(0); spring.anim.SetTrigger("Hit"); } if (col.GetComponent <Spring_Proprieties>().LockControl) { Inp.LockInputForAWhile(col.GetComponent <Spring_Proprieties>().LockTime, false); } } } if (col.tag == "Bumper") { Actions.Action01.JumpBall.SetActive(false); if (Actions.Action08 != null) { if (Actions.Action08.DropEffect.isPlaying == true) { Actions.Action08.DropEffect.Stop(); } } if (col.GetComponent <Spring_Proprieties>() != null) { spring = col.GetComponent <Spring_Proprieties>(); if (spring.IsAdditive) { // transform.position = col.transform.GetChild(0).position; if (col.GetComponent <AudioSource>()) { col.GetComponent <AudioSource>().Play(); } Actions.Action00.CharacterAnimator.SetInteger("Action", 0); if (Actions.Action02 != null) { Actions.Action02.HomingAvailable = true; } Player.rigidbody.velocity += (Player.transform.position - spring.transform.position) * spring.SpringForce; } else { //transform.position = col.transform.GetChild(0).position; if (col.GetComponent <AudioSource>()) { col.GetComponent <AudioSource>().Play(); } Actions.Action00.CharacterAnimator.SetInteger("Action", 0); if (Actions.Action02 != null) { Actions.Action02.HomingAvailable = true; } Player.rigidbody.velocity = (Player.transform.position - spring.transform.position) * spring.SpringForce; } if (col.GetComponent <Spring_Proprieties>().LockControl) { Inp.LockInputForAWhile(col.GetComponent <Spring_Proprieties>().LockTime, false); } } } //Monitors if (col.tag == "CancelHoming") { if (Actions.Action == 2) { Vector3 newSpeed = new Vector3(1, 0, 1); Actions.ChangeAction(0); newSpeed = new Vector3(0, HomingBouncingPower, 0); ////Debug.Log (newSpeed); Player.rigidbody.velocity = newSpeed; //Player.transform.position = col.ClosestPoint (Player.transform.position); if (Actions.Action02 != null) { Actions.Action02.HomingAvailable = true; } } } }
public void OnTriggerEnter(Collider col) { //Speed Pads Collision if (col.tag == "SpeedPad") { if (col.GetComponent <SpeedPadData>() != null) { transform.rotation = Quaternion.identity; //ResetPlayerRotation if (col.GetComponent <SpeedPadData>().LockToDirection) { Player.rigidbody.velocity = Vector3.zero; Player.AddVelocity(col.transform.forward * col.GetComponent <SpeedPadData>().Speed); } else { Player.AddVelocity(col.transform.forward * col.GetComponent <SpeedPadData>().Speed); } if (col.GetComponent <SpeedPadData>().Snap) { transform.position = col.transform.position; } if (col.GetComponent <SpeedPadData>().isDashRing) { Actions.ChangeAction(0); Actions.Action00.CharacterAnimator.SetBool("Grounded", false); Actions.Action00.CharacterAnimator.SetInteger("Action", 0); } if (col.GetComponent <SpeedPadData>().LockControl) { Inp.LockInputForAWhile(col.GetComponent <SpeedPadData>().LockControlTime, true); } if (col.GetComponent <SpeedPadData>().AffectCamera) { Vector3 dir = col.transform.forward; Cam.SetCamera(dir, 2.5f, 20, 5f, 1); col.GetComponent <AudioSource>().Play(); } } } //Rings Collision if (col.tag == "Ring") { RingAmmount += 1; Instantiate(RingCollectParticle, col.transform.position, Quaternion.identity); Destroy(col.gameObject); } if (col.tag == "MovingRing") { if (col.GetComponent <MovingRing>() != null) { if (col.GetComponent <MovingRing>().colectable) { RingAmmount += 1; Instantiate(RingCollectParticle, col.transform.position, Quaternion.identity); Destroy(col.gameObject); } } } //Hazard if (col.tag == "Hazard") { DamagePlayer(); HedgeCamera.Shakeforce = EnemyDamageShakeAmmount; } //Enemies if (col.tag == "Enemy") { HedgeCamera.Shakeforce = EnemyHitShakeAmmount; //If 1, destroy, if not, take damage. if (Actions.Action == 3) { col.transform.parent.GetComponent <EnemyHealth>().DealDamage(1); updateTargets = true; } if (Actions.Action00.CharacterAnimator.GetInteger("Action") == 1) { if (col.transform.parent.GetComponent <EnemyHealth>() != null) { if (!Player.isRolling) { Vector3 newSpeed = new Vector3(1, 0, 1); if (StopOnHommingAttackHit && Actions.Action == 2) { newSpeed = new Vector3(0, 0, 0); newSpeed = Vector3.Scale(Player.rigidbody.velocity, newSpeed); newSpeed.y = BouncingPower; } else if (StopOnHit) { newSpeed = new Vector3(0, 0, 0); newSpeed = Vector3.Scale(Player.rigidbody.velocity, newSpeed); newSpeed.y = BouncingPower; } else { newSpeed = Vector3.Scale(Player.rigidbody.velocity, newSpeed); newSpeed.y = BouncingPower; } Player.rigidbody.velocity = newSpeed; } col.transform.parent.GetComponent <EnemyHealth>().DealDamage(1); updateTargets = true; Actions.ChangeAction(0); } } else if (Actions.Action != 3) { DamagePlayer(); } } //Spring Collision if (col.tag == "Spring") { if (col.GetComponent <Spring_Proprieties>() != null) { spring = col.GetComponent <Spring_Proprieties>(); if (spring.IsAdditive) { transform.position = col.transform.GetChild(0).position; if (col.GetComponent <AudioSource>()) { col.GetComponent <AudioSource>().Play(); } Actions.Action00.CharacterAnimator.SetInteger("Action", 0); Actions.Action02.HomingAvailable = true; Player.rigidbody.velocity += (spring.transform.up * spring.SpringForce); Actions.ChangeAction(0); spring.anim.SetTrigger("Hit"); } else { transform.position = col.transform.GetChild(0).position; if (col.GetComponent <AudioSource>()) { col.GetComponent <AudioSource>().Play(); } Actions.Action00.CharacterAnimator.SetInteger("Action", 0); Actions.Action02.HomingAvailable = true; Player.rigidbody.velocity = spring.transform.up * spring.SpringForce; Actions.ChangeAction(0); spring.anim.SetTrigger("Hit"); } if (col.GetComponent <Spring_Proprieties>().LockControl) { Inp.LockInputForAWhile(col.GetComponent <Spring_Proprieties>().LockTime, false); } } } }