[SOLVED] Shooting BoundingBox Ray Check

I’m doing my next text and creating a FPS shooter game. Creating a Wolfstein Clone. The enemies are QUADS. When I do a ray check to see if you hit anything after firing.

The QUAD boundingBox is “HUGE” compared to the actually graphics that get drawn. Many pixels with Alpha = 0.

Can I alter the world Bounds or what is check to make the bounding box smaller so it is closer to the size of the drawn pixels?

Or is there a better way of handling this?


You could also convert the intersection point of the ray/quad to pixel location and then check if the texture has alpha > 0 at that spot.
The ImageRaster class has a getPixel() method.

1000ml indicates the most accurate way… and probably the most satisfying.

But you can give geometry whatever bounds you want… unless you are batching them together.

Since the ray collision stuff usually does a bounds check first, this should fool it into skipping the actual quad check when outside the custom bounds. But if you’ve batched geometry together then it will still be hitting the quad directly.

…then you are back to 1000ml’s suggestion or using a second set of invisible quads that represent your hit boxes and then use those for picking.

What does that mean? Never heard it.

I’m not batching the enemies, not enough of them to worry about for scene.

Can you point me to this 1000ml’s suggestion. Having my own hit box is a very simple solution.

Thanks for the ideas.

Meaning, convert the collision point into a texture coordinate for that quad… then lookup the texture value. It would give you pixel-perfect collisions.

…personally, I’d still probably want a smaller hit box as it would eliminate a lot of unnecessary checks. And maybe it’s good enough on its own.

I did the smaller hit box and it works great and is so simple and for a pixel style 80/90s game it is perfect.

Thanks again for you direction and my many questions.

1 Like

Yeah, and likely exactly what those old games did, too. :slight_smile: