How to detect if vector is in bounding box extent?

Hi,

I’m trying to figure out how to detect if a vector is inside a collision box or not. Is there already a function for this? If not any help, ideas on how to solve this would be greatly appreciated! :smiley:

Not that I know of.

It kinda depends on what you need to know. If it’s for a single bounding box the math to check it is simple enough and I’d just do that on my own.

Otherwise you could try to create a collision sphere with a radius of 0.1 or something like that which can give you a list of all overlapping actors since it’s within the collision system. (sphere because it’s slightly cheaper resource wise and easy to setup).

Those are the two solutions I can think off from the top of my head.

Thanks! Ended up creating a custom collision object channel and creating collision boxes. Then i checked for overlap like you suggested. Works perfect!

You can check if the vector elements are between the vector elements representing the corners on each end of a diagonal line.

For example, you have a box defined by two vectors; StartVec and EndVec.

Then you have your vector MyVec. Assuming that they are in the same coordinate system you can check if

MyVec.x is between StartVec.x and EndVec.x
MyVec.y is between StartVec.y and EndVec.y
MyVec.z is between StartVec.z and EndVec.z

If these are all true then it is within the box.

1 Like

Thanks I think I understand. Though I’m not sure how one would go about to get the start and end vectors from a collision volume.

You can simply get the center vector and add the vector from the center to each corner. You get the center by using the node GetWorldLocation.

Okay thanks!