Restrict Player To Camera Field Of View

Hello,

So, I’m working on some side-scrolling 2.5D levels, and I came up with a boundary box for the player (who is in a plane).

The issue I just realized is that the boundary that I made doesn’t scale with the field of view of the camera, so, depending on the display, the player will hit the invisible walls in different (delta)-distances relative to the field of view.

The pictures below show the plane hitting the top boundary; it can go no higher:

(In-Editor)

(Full-Screen)

(Miniature)

You can see how far the plane is away from the top of the screen when you compare the In-Editor to Miniature.

I need for the boundary to be consistent for all screens.

You can use constrain aspect ration but you will get black bars especially on wide screen

You can also play around the width of viewport and field of view but not sure about the correct formula, might want to dig around that

2 Likes

So far I think you’re right on the money.

Working on it!!!

After 4 hours of wrestling with equations, I realized that the only thing I needed to change was the Z value, because Unreal automatically makes the X and Y adjustments for you; how nice.

WISH I’D KNOWN.

My solution looks similar to yours:

I divide the default aspect ratio (16:9) by the new one, (whatever it is), and I apply that value to the Z-axis of my actor.

PS: Irrelevant, but I was born the year of the Rabbit. You seem to like them. They’re cute, when they don’t die for no reason.

1 Like

Nice, at least this one we did it in less than a day :smile:

I like rabbit too, that my character cobaye for all my plugins on the market :innocent:

So you are making a Battle Squadron style game ?:o

1 Like

Small victories.

Dunno yet. I’m working on it. If I can get it to work, yes. Otherwise, I’ll scrap the idea.

Fingers crossed I pull it off!

As always, THANK YOU. You are a frequent life and time-saver.

1 Like

Always a pleasure :hugs:

And good luck for that new game :innocent:, I started making my indie game too since yesterday, Fab Marketplace isn’t anymore profitable for me, it pretty bad this month.
Everyone is complaining about the AI flood content that making Fab unusable so most sellers are getting fewer sales. :face_with_head_bandage:

1 Like

You might want to restrict the movement to a specific aspect ratio if you don’t want your players to resize the window in weird ways to have an optimal play area.

1 Like

I’ve actually been on Reddit trying to see if I was the crazy one for not liking FAB system. Yeah, a lot of people have your same issue.

Good luck to us both! :cold_face: :four_leaf_clover: :moneybag:

@JAuzanneau

HA! Yeah, I’ve considered it. (I, myself, look for EVERY loophole when I play video games.) When I finish prototyping the actual combat, I’ll see how it works. It’s flying only, so it may not actually matter all that much. Or I could be deluded. Unsure at the moment.

1 Like