public override void Step(CharControlMotor player, float deltaTime) { player.UpdateDirection(player.input.horizontal); player.HandleSlopeFactor(deltaTime); player.HandleAcceleration(deltaTime); player.HandleFriction(deltaTime); player.HandleGravity(deltaTime); player.HandleFall(); if (!player.HandleLedgeCheck().Item2) { player.state.ChangeState <WalkPlayerState>(); } if (player.input.actionDown) { player.HandleJump(); } if (player.HandleLedgeCheck().Item1) { player.state.ChangeState <LedgeGrabStateFront>(); } if (player.input.horizontal != 0 || player.velocity.x != 0) { player.state.ChangeState <WalkPlayerState>(); } }
public override void Step(CharControlMotor player, float deltaTime) { if (!player.HandleLedgeCheck().Item1) { player.state.ChangeState <WalkPlayerState>(); } if (player.HandleLedgeCheck().Item2) { player.state.ChangeState <LedgeGrabStateBack>(); } if (player.input.actionDown) { player.HandleJump(); } if (player.input.horizontal != 0) { if (Mathf.Abs(player.velocity.x) >= player.stats.minSpeedToBrake) { player.state.ChangeState <BrakePlayerState>(); } else { if (player.velocity.x > 0) { player.velocity.x = -player.stats.turnSpeed; } else { player.velocity.x = player.stats.turnSpeed; } } } }
public override void Step(CharControlMotor player, float deltaTime) { var PushResult = player.HandlePushCheck(); if (PushResult.Item1) { if (player.input.actionDown) { player.HandleJump(); } //apply push to physical object if (player.input.horizontal != 0) { var rigidbody = PushResult.gameObject.GetComponent <Rigidbody>(); rigidbody.AddForce(player.skin.transform.right.normalized * player.input.horizontal); } if (Mathf.Sign(player.velocity.x) != Mathf.Sign(player.input.horizontal)) { player.state.ChangeState <WalkPlayerState>(); } } else { player.state.ChangeState <WalkPlayerState>(); } }
public override void Step(CharControlMotor player, float deltaTime) { player.HandleSlopeFactor(deltaTime); player.HandleFriction(deltaTime); player.HandleDeceleration(deltaTime); player.HandleGravity(deltaTime); player.HandleFall(); ///* Controls the height of the playerspin ~Birb64 */// if (player.PlayerObject.transform.eulerAngles.z > 100 && player.PlayerObject.transform.eulerAngles.z < 180) { player.PlayerObject.GetComponent <PlayerMotor>().height = 0.012f * player.PlayerObject.transform.eulerAngles.z; } if (player.PlayerObject.transform.eulerAngles.z < 260 && player.PlayerObject.transform.eulerAngles.z > 180) { player.PlayerObject.GetComponent <PlayerMotor>().height = 0.012f * (180 - Mathf.Abs(player.PlayerObject.transform.eulerAngles.z - 180)); } ///* Controls the width of the playerspin ~Birb64 */// if (player.PlayerObject.transform.eulerAngles.z > 30 && player.PlayerObject.transform.eulerAngles.z < 180) { player.PlayerObject.GetComponent <PlayerMotor>().wallExtents = 0.01f * player.PlayerObject.transform.eulerAngles.z; } if (player.PlayerObject.transform.eulerAngles.z < 330 && player.PlayerObject.transform.eulerAngles.z > 180) { player.PlayerObject.GetComponent <PlayerMotor>().wallExtents = 0.01f * (180 - Mathf.Abs(player.PlayerObject.transform.eulerAngles.z - 180)); } else if (player.PlayerObject.transform.eulerAngles.z < 180 || player.PlayerObject.transform.eulerAngles.z > 260) { player.PlayerObject.GetComponent <PlayerMotor>().wallExtents = 0.02f; } if (player.grounded) { if (player.input.actionDown) { player.HandleJump(); } else if (Mathf.Abs(player.velocity.x) < player.stats.minSpeedToUnroll) { player.state.ChangeState <WalkPlayerState>(); } } else { player.state.ChangeState <JumpPlayerState>(); } }
public override void Step(CharControlMotor player, float deltaTime) { player.HandleDeceleration(deltaTime); player.HandleGravity(deltaTime); player.HandleFall(); if (player.grounded && (Mathf.Sign(player.input.horizontal) != Mathf.Sign(player.direction))) { if (player.input.actionDown) { player.HandleJump(); } else if ((Mathf.Abs(player.velocity.x) <= player.stats.turnSpeed) || player.input.horizontal == 0) { player.state.ChangeState <WalkPlayerState>(); } } else { player.state.ChangeState <WalkPlayerState>(); } }
public override void Step(CharControlMotor player, float deltaTime) { player.HandleSlopeFactor(deltaTime); player.HandleFriction(deltaTime); player.HandleDeceleration(deltaTime); player.HandleGravity(deltaTime); player.HandleFall(); if (player.grounded) { if (player.input.actionDown) { player.HandleJump(); } else if (Mathf.Abs(player.velocity.x) < player.stats.minSpeedToUnroll) { player.state.ChangeState <WalkPlayerState>(); } } else { player.state.ChangeState <JumpPlayerState>(); } }
public override void Step(CharControlMotor player, float deltaTime) { player.UpdateDirection(player.input.horizontal); player.HandleSlopeFactor(deltaTime); player.HandleAcceleration(deltaTime); player.HandleFriction(deltaTime); player.HandleGravity(deltaTime); player.HandleFall(); if (player.grounded) { if (player.input.actionDown) { player.HandleJump(); } else if (player.input.down) { if (Mathf.Abs(player.velocity.x) > player.stats.minSpeedToRoll) { player.sonicState = CharControlMotor.SonicState.Rolling; player.state.ChangeState <RollPlayerState>(); //player.PlayAudio(player.audios.spin, 0.5f); } else if (player.angle < player.stats.minAngleToSlide) { player.state.ChangeState <CrouchPlayerState>(); } } else if (player.input.up) { // Changing this condition because it causes animation bugs - Arcy //if (Mathf.Abs(player.velocity.x) < player.stats.minSpeedToRoll) if (player.velocity.x == 0) { player.state.ChangeState <LookUpPlayerState>(); } } else if (Mathf.Sign(player.velocity.x) != Mathf.Sign(player.input.horizontal) && player.input.horizontal != 0) { if (Mathf.Abs(player.velocity.x) >= player.stats.minSpeedToBrake) { player.state.ChangeState <BrakePlayerState>(); } else { if (player.velocity.x > 0) { player.velocity.x = -player.stats.turnSpeed; } else { player.velocity.x = player.stats.turnSpeed; } } } else if (player.HandleLedgeCheck().Item1) { player.state.ChangeState <LedgeGrabStateFront>(); } else if (player.HandleLedgeCheck().Item2) { player.state.ChangeState <LedgeGrabStateBack>(); } else if (player.HandlePushCheck().Item1&& Mathf.Abs(player.input.horizontal) > 0) { player.state.ChangeState <PushPlayerState>(); } } }