Help with bounding boxes?
#1
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.
Reply
Thanks given by:
#2
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.
Reply
Thanks given by: DiamondToaster
#3
Ok, I would love to use bounding boxes. They make territorial checks much easier. Thanks for the effort.
Reply
Thanks given by:
#4
I checked cBoundingBox it works for positions x, y, z and for the Vector3d. Maybe you have something wrong with your table?
Reply
Thanks given by:
#5
Huh, I probably did. I'll check it out.
Reply
Thanks given by:
#6
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.
Reply
Thanks given by:
#7
Try printing the coords of both the bbox and the player pos; perhaps there is a rounding error somewhere.
Reply
Thanks given by:
#8
[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
Reply
Thanks given by:
#9
That seems like the numbers are right. So what's your current code?
Reply
Thanks given by:
#10
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
Reply
Thanks given by:




Users browsing this thread: 4 Guest(s)