- Home /
Question by
ProfMonkey07 · Dec 07, 2020 at 08:31 PM ·
collisioncharactercontrollerphysics2d
character bumps when going between overlapping or side by side colliders
so when the player goes from one collider to another, as happens almost always with a tilemap collider since its a bunch of colliders, 1 for each tile, the player bumps, like it goes up a tiny bit and comes down, why is this and how do I fix it? here is the jumping part of my player controller, the movement is just generic input.getaxis horizontal stuff:
public float jumpPressedRemember;
public float jumpPressedRememberTime = .1f;
private bool isGrounded;
public float checkRadius;
public Transform groundCheck;
public LayerMask isGround;
public float jumpHeight;
private Rigidbody2D rb;
private float jumpTimeCounter;
public float jumpTime;
private bool isJumping;
// Start is called before the first frame update
void Start()
{
rb = GetComponent<Rigidbody2D>();
}
// Update is called once per frame
void Update()
{
//jumping
jumpPressedRemember -= Time.deltaTime;
if (Input.GetKeyDown("space"))
{
jumpPressedRemember = jumpPressedRememberTime;
}
if(Input.GetKey(KeyCode.Space) && isJumping == true)
{
if(jumpTimeCounter > 0) {
jumpTimeCounter -= Time.deltaTime;
rb.velocity = Vector2.up * jumpHeight;
}
}
if ((jumpPressedRemember > 0) && isGrounded == true)
{
isJumping = true;
jumpTimeCounter = jumpTime;
jumpPressedRemember = 0;
rb.velocity = Vector2.up * jumpHeight;
}
if (Input.GetKeyUp(KeyCode.Space))
{
isJumping = false;
}
}
void FixedUpdate()
{
//groundcheck
isGrounded = Physics2D.OverlapCircle(groundCheck.position, checkRadius, isGround);
}
}
Comment