Circular collider using `setCircle` is not centred properly

I want to create a circular collider for my sprite so I added this.setCircle(this.body.halfWidth) in my characters constructor but the collider is not centred on the object. I added a red circle on the objects position (x,y) as shown on the picture
Screenshot from 2020-12-02 21-16-43

The default box collider is centred as expected.
Screenshot from 2020-12-02 21-16-13

Use the offsetX and offsetY arguments.

can you explain what should be how to set the offsets?
Isn’t origin set to (0.5,0.5) by default?

Arguments to setCircle(). Something like

this.setCircle(this.body.halfWidth, 0, this.body.halfHeight - this.body.halfWidth);

The physics body is always positioned from the top-left of the game object.

1 Like

@samme it’s working :grinning:

But how is “The physics body is always positioned from the top-left of the game object” is explaining offsetX=0 and offsetY= halfHeight - halfWidth ?

It works because you used halfWidth as the radius. But generally, you increased the body height, so you need to shift it upwards to recenter it.