- Home /
Question by
Atto2O · Apr 08, 2019 at 05:58 PM ·
colliderbugcharactercontrollerjump
CharacterController stop the jump near the top of boxes (collider problems?)
The character gets stuck when I try to jump closer to a box (and moving into box direction). Some clue what can be happening and how to solve it?
It seems character get stuck when the character controller Collider star reducing the radius.
character controller:
jump code:
public void jump()
{
if (OnSlope())
{
print("controller.height: " + controller.height);
controller.Move(Vector3.down * controller.height / 2 * slopeForce * Time.deltaTime);
}
print("key press jump");
JumpMode = true;
StartCoroutine(JumpEvent());
}
private IEnumerator JumpEvent()
{
controller.slopeLimit = 90.0f;
float timeInAir = 0.0f;
print("IEnumerator JumpEvent");
do
{
float jumpForce = jumpFallOff.Evaluate(timeInAir);
controller.Move(Vector3.up * jumpForce * jumpMultiplier * Time.deltaTime);
timeInAir += Time.deltaTime;
//print("INTOWHILE JumpEvent");
yield return null;
}
while (!controller.isGrounded && controller.collisionFlags != CollisionFlags.Below);// .Above); ((controller.collisionFlags & CollisionFlags.Below) == 0) && ((controller.collisionFlags & CollisionFlags.Above) == 0));//
controller.slopeLimit = 45.0f;
JumpMode = false;
}
Comment