This project has moved and is read-only. For the latest updates, please go here.

How to get body width and height

Nov 30, 2009 at 8:53 PM

Hello, I have trouble find how to get body size, I found only BoxGeom.AABB.Width an .Height but thats not what I'm searching

Nov 30, 2009 at 10:27 PM

The AABB does indeed give you the width and height of your geometry as it is a bounding box to the geometry. It all depends on the shape of your geometry and the rotation applied on the geometry. If you have zero rotation, the AABB.Width and AABB.Height will be the width and height of the geometry.

Nov 30, 2009 at 11:00 PM

Yeah it does but I have a rectangle and if it rotates, then AABB doesn't give right information. So there's no direct way to get it?

Nov 30, 2009 at 11:04 PM

The physics engine does not keep width and hight values. It operates on points in space and not any specific shapes. The only way is to use the AABB width and height.

Dec 5, 2009 at 1:27 AM

A way I did this was I simply saved the size used when the geom was created, and stored it in a vector2 within my game object. It works well, however if you intend to set the Size value of your object you'll need to rebuild the vertices in the geom.