Help with bounding boxes? - Printable Version +- Cuberite Forum (https://forum.cuberite.org) +-- Forum: Plugins (https://forum.cuberite.org/forum-1.html) +--- Forum: Plugin Discussion (https://forum.cuberite.org/forum-8.html) +--- Thread: Help with bounding boxes? (/thread-1813.html) |
Help with bounding boxes? - DiamondToaster - 03-01-2015 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. RE: Help with bounding boxes? - worktycho - 03-01-2015 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. RE: Help with bounding boxes? - DiamondToaster - 03-01-2015 Ok, I would love to use bounding boxes. They make territorial checks much easier. Thanks for the effort. RE: Help with bounding boxes? - Seadragon91 - 03-01-2015 I checked cBoundingBox it works for positions x, y, z and for the Vector3d. Maybe you have something wrong with your table? RE: Help with bounding boxes? - DiamondToaster - 03-02-2015 Huh, I probably did. I'll check it out. RE: Help with bounding boxes? - DiamondToaster - 03-03-2015 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. RE: Help with bounding boxes? - xoft - 03-03-2015 Try printing the coords of both the bbox and the player pos; perhaps there is a rounding error somewhere. RE: Help with bounding boxes? - DiamondToaster - 03-03-2015 [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. RE: Help with bounding boxes? - xoft - 03-03-2015 That seems like the numbers are right. So what's your current code? RE: Help with bounding boxes? - DiamondToaster - 03-04-2015 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. |