Perspective camera issue

Hi! For my platformer game, I’m using the perspective camera instead of the orthographic for a variety of reasons (parallax effect, particle issues, etc.) and I’ve come across a problem.

Let’s say I have 2 objects: One in the front, and one in the back. If the player closes in to one of them, and then moves away from it, the objects sort of overlap differently. I don’t really know how to explain it, so here you go:

What it should look like at all times:

What it actually looks like from the other side (after the camera moves):


As you can see, the boulder that was in front went to the back, and the one in back went to the front. This does not happen in orthographic, but I can’t use an orthographic camera.

I haven’t really tried much, since I don’t really know what to try. But I can at least tell you that offsetting the Y axis doesn’t change anything.

How can I fix this? Thank you so much!

Hello,

I guess this is what happens.

38554-iwannarock.png

I think the best way would be if you built a system for setting a “z-index” on the objects the that overrides how things are rendered. So that the ones with the greatest z-index are rendered on top of the lesser.

Maybe something like this: How to get a simple X-Ray Vision (ZBuffer override)? - Rendering - Unreal Engine Forums

(“iwannarock.png” hahaha good one)

Thanks for the illustration :3 I thought that’s how it happened, I just don’t know how to go about disabling it.

I have an idea of what you mean… But I’m still confused. Sorry to ask you of more, but could you elaborate a bit on that? :slight_smile:

Sorry I didn’t reply sooner! :slight_smile:

Are the boulder actors always facing the camera or something? Do they turn towards the camera like 2d sprites?

No worries!

Well… I think they are. They are literally just sprites placed next to each other with different Y-values. And what do you mean by “do they turn”? I’m guessing they do, since that’s basic perspective camera behavior. I’m clearly not well-versed in this though, so forgive me xP

Thanks!

I’m not home right now, but I’ll give that a shot as soon as I can :3

Have you tried this? https://answers.unrealengine.com/questions/146920/z-buffer-problems-with-paper2d-sprites-using-trans.html