Cuberite Forum

Full Version: Help with bounding boxes?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
For some reason, I'm unable to call cBoundingBox:IsInside(). I wanted to to something like this :

(A table object "Arena" contains a bounding box btw.)

if Arena.BoundingBox:IsInside(Player:GetPosition()) then
    -- do stuff
end

But when I call that, it says something like "given const Vector3d: expected cBoundingBox"

Ok, So I make a bounding box with the player dimensions:

local PlayerBoundingBox = cBoundingBox(Player:GetPosition(), 0.4, 1.8)
if Arena.BoundingBox:IsInside(PlayerBoundingBox) then
    -- do stuff
end

But is spits out "given [no object]: const Vector3d expected"

What am I doing wrong? Any help would be appreciated.
I think this is something todo with the way tolua resolves overloads but Im not at my dev machine right now so can't check.
Ok, I would love to use bounding boxes. They make territorial checks much easier. Thanks for the effort.
I checked cBoundingBox it works for positions x, y, z and for the Vector3d. Maybe you have something wrong with your table?
Huh, I probably did. I'll check it out.
I somehow fixed it. Mot really sure though. The problem though is that the function now always returns false, even if the player position is directly in the center of the box.
Try printing the coords of both the bbox and the player pos; perhaps there is a rounding error somewhere.
[19:43:40] MinX 39
[19:43:40] MinY 61
[19:43:40] MinZ 53
[19:43:40] MaxX 51
[19:43:40] MaxY 69
[19:43:40] MaxZ 64
[19:43:40] PlayerX 45
[19:43:40] PlayerY 65
[19:43:40] PlayerZ 58.5

Not really sure whats going on here. Sad
That seems like the numbers are right. So what's your current code?
https://github.com/DevToaster/MCArena

Here's a repo. Keep in mind that the code is completely butchered for debug purposes in order to find that bug. Tongue