What is the CollisionBox's getRadius equivalent? (Solved)

Hello everyone, as the title states I,m looking the getRadius equivalent for the CollisionBox, I know getRadius gets the distance between a CollisionSphere’s center and it’s farthest point, and i,m looking for the same for the Collision Box.

I thought I saw a equivalent just before the manual was changed, well anyway, I thank anyone who is willing to help.

The API suggests a few possibilities, including “getDimensions” and (in the parent-class) “getBounds”.

radius = (box.max - box.center).length()

rdb: I tried this, but it is appears to be getting a larger result then I wanted, and I think it is because the max is one of it’s points rather than one of the 6 faces of the box, I should have elaborated that I wanted the distance between the center and one of the faces, so I apologize for that.

Thaumaturge: I did check out the page you linked and tried a few stuff from there, interestingly enough I find if I use getDimensions().getX() then divide by 2 I get a pretty accurate result.


So thanks to both you, for getting me out of a stump.

1 Like

I’m glad that you found a solution. :slight_smile:

Indeed, based on your new description that should be exactly what you want: after all, the distance from the centre of a box to the centre of one of its faces is half of the dimension of the box in that direction.

To illustrate:

Y
^
: ___________
: |         |
: |         |
: |    o----| dist
: |         |
: |         |
: ___________
:................> X
 A     B     C

o = centre of box; X-coordinate of centre = B
Dimension on X-axis = C - A
Distance, "dist", from o to face = C - B =
                                   half C - A = 
                                   half Dimension on X-axis
1 Like