Rigidbody shaking when colliding with collider.

Hi, I have a script that goes the following

public bool IsTouchingGround;
public int speed = 5;
public LayerMask ground;
public Transform GroundCheck;
public float GroundCheckRadius;

Jump();
Vector3 movement = new Vector3(Input.GetAxis(“Horizontal”), 0f, 0f);
transform.position += movement * Time.deltaTime * speed;

IsTouchingGround = Physics2D.OverlapCircle(GroundCheck.position, GroundCheckRadius, ground);

public void Jump()
{
if (Input.GetButtonDown(“Jump”) && (IsTouchingGround))
{
GetComponent().AddForce(new Vector2(0f, 7f), ForceMode2D.Impulse);
}
}

And camera script

public bool cmr = true;
public Transform Player;
// Update is called once per frame
private void LateUpdate()
{
{
if (cmr == true)
{
gameObject.transform.position = new Vector3(Player.position.x, Player.position.y, Player.position.z - 10);
}
}
}
}

When my player collides with any colliders it starts shaking a lot and its very annoying. Thanks :smile:

Please use code-tags when posting code. Also, there’s a dedicated physics forum here.

My only question is, why add a Rigidbody2D whose job it is to update the Transform position/rotation to where you want the physics to move to and then overwrite that by directly writing to the Transform yourself?

If you want physics movement then use the Rigidbody2D API to get it done. In short, choose who’s going to update the Transform … you or the physics engine.

Also, the code above isn’t real code, it won’t compile at all.