Checking if an entity is in a box

Blitz3D Forums/Blitz3D Programming/Checking if an entity is in a box

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

first of all get your bounding boxes right, try making a red cube that is semi transparent to show your bounding box, this will help you see if it's correct. Then if you have a propper box, a simple pure maths way of doing the check is by checking of the players x,y,z is within every boundary (a box has 6 boundaries, you could call em: xstart,xend,ystart etc.) so if the x > xStart and the x < xEnd, the y > yStart etc. then the players current position is in the box.

However the player will no doubt have a radius, to compensate for that you need to expand the box by the radius, like this: if the x > (xStart-radius) and the x < (xEnd+radius), the y > (yStart-radius) etc. then the players current radius is, atleast partialy, inside the bounding box. Hope that helps ya. You really want to shy away from using entityvisible for stuff like that it's a bit slow.