I have two issues: Collider issues and jittery movement

This is not from a course btw, I just need some help on a project. I am making a zombie 3D shooter game. The first problem I have is the character is jittery when falling when he jumps but he is otherwise smooth when jumping. I have the Rigidbody set to interpolate. I have the camera move in late update. I have my movement for my character in fixed update!

The second problem is I am able to push through walls with my player. I am using a Rigidbody for my character and using .movePosition() function to move my player.

What could be the problem with both of them? If you need more info, I can give more info on the issue! THANKS!

The jittery can be a result of many things, how are you handling the movement, for instance, or how are you handling the jump, having a look a the code and some video would be nice to help you further.

For your second issue. Have you tried setting the Rigidbody’s Collision Detection to Continuos?

private void MovePlayer()
    {
        CamF = cam.transform.forward;
        CamR = cam.transform.right;

        CamF.y = 0;
        CamR.y = 0;

        CamF = CamF.normalized;
        CamR = CamR.normalized;

        Vector3 positionToMoveTo = CamF * input.y + CamR * input.x;
        rb.MovePosition((Vector3)transform.position + (positionToMoveTo * speed * Time.fixedDeltaTime));


        if(animator != null)
        {
            animator.SetFloat("VelX", input.x);
            animator.SetFloat("VelY", input.y);
        }

        if(jump)
        {
            rb.velocity = new Vector3(rb.velocity.x, jumpForce ,rb.velocity.z);
        }
    }


    private void GetInput()
    {
        input = new Vector2(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical"));
    }

MovePlayer() is done in FixedUpdate() and GetInput is done in Update().

Also, here is the logic for the jump bool which is done in the update function

            if(Input.GetButtonDown("Jump") && IsGrounded())
            {
                jump = true;
            }
            if(IsGrounded() == false)
            {
                jump = false;
            }

For the second problem, I do have the collision detection set to continuous. THANKS!

All of your issues are caused due to the interpolation setting according to my experiments with your code, you’ll have to change that or adjust your other objects if you truly need the rigidbody set to Interpolate.

If found the jittery issue is due to my camera’s interpolation! As for the rigid body, that is still an issue with that.

Thanks for the help! This can be closed now.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms