Search Unity

Bug Player walking through walls when going fast

Discussion in 'Editor & General Support' started by MaynieClan, Jan 19, 2023.

  1. MaynieClan

    MaynieClan

    Joined:
    Jan 15, 2023
    Posts:
    1
    I have a problem that when my player walks up to a wall fast enough, they pass through it. At slower speeds the collision works like its supposed to and stops me from walking forward.

    This is how I am moving my player, which is attached to a capsule game object.
    private void FixedUpdate()
    {
    float moveHorizontal = Input.GetAxisRaw("Horizontal");
    float moveVertical = Input.GetAxisRaw("Vertical");
    Vector3 movement = Vector3.zero;

    movement = playerCamera.transform.right * moveHorizontal + playerCamera.transform.forward * moveVertical;
    movement.y = 0;

    if (isSprinting && sprintCoolTimer <= 0)
    {
    movement = movement.normalized * movementSpeed * sprintSpeed;
    }
    else
    {
    movement = movement.normalized * movementSpeed;
    }

    rigidbodyComponent.MovePosition(transform.position + movement * Time.deltaTime);

    This is what components I have on my player capsule, and I have also checked to see if it is the rigid body interpolate or collision detection, and still my player phases though when sprintin.
    upload_2023-1-19_21-58-58.png

    The wall I am phasing through only has a box collider components and that's it.

    Thanks in advance if anyone can help me out with this, as its been bugging me all night :)
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,674
    You say this ^ ^ ^ but I still see Discrete collision detection above.

    Try setting your collision detection to Continuous or Continuous Dynamic
     
    UFODriverr likes this.