Is it possible to cast a ray but ignore Z position?

Say I have a ‘3D’ platformer that is viewed from a side-on perspective, I want to shoot a ray down from the player and see if there are any platforms below him on the X plane, regardless of their Z position. Is this possible?

That’s a good question !

Not that I know of … I don’t think there’s a way to “flatten cast”, which would be clever in PhysX (but I’m struggling to think of much utility for it outside of 2.5D !)

normally in a 2.5D production, you’d have all the “relevant things” in the same z plane…

But here’s a trick:

the colliders/triggers you have on your objects…

There’s no reason they cannot be QUITE DEEP!!

for example, you have “clouds” on “layer 6” (6m from the camera) and “spaceships” happen to be on “layer 7” (7m from the camera). You want to cast from one to the other … just made the colliders a couple meters deep in each case.

Another idea on the same … always make ALL your colliders deep enough to cover ALL your “layers” !

Don’t forget too, it’s very easy to SHOOT A FEW RAYS.

So in the example if you are in layer 5, and you are concerned about objects in layers 5 AND 10 AND 15 … simply shoot three rays from where you are, in those three layers.

Makes sense ?

(BTW by “layers” I simply mean indeed the z distance from the lens. often in a 2.5D production they’ll get to seem like different functional “layers” to you.)

A final point … when you’re doing such a production, you have to ask “what should you put in the various layers”. Certainly the answer is pretty much “stuff you’ll have to cast against and collide with each other should all go in the same layer!!” So really that could be a better answer depending on your situation.