Hi guys!
I often use foreground graphics that should be "aligned" to the side of the scene (left for example). If I add a Parallax2D component to that game object, I can set its position and movement fine by tweaking the Depth value. But for some reason that component takes into account the screen ratio, so when I resize the Game window, the foreground graphics are moved to a different position. I tried tweaking the min/max constraints on the Parralax2D component but haven't been able to position these in a way that works from 5:4 to super wide screen...
Any tips would be greatly appreciated 👍
It looks like you're new here. If you want to get involved, click one of these buttons!
Comments
Parallax2D does not account for screen ratio directly, but If you're using the Dynamic Camera Limits wiki script, then that camera's position does depend on the ratio, which in turn will affect the parallax position.
Try this instead:
That almost works, but it breaks apart when the screen ratio gets too wide:
https://1drv.ms/u/s!Amz_vh8OYDX3vKt15F7uVgYmeMhxJA?e=QPUw0Y
Here's a fresh repro that illustrates the problem:
https://1drv.ms/u/s!Amz_vh8OYDX3vKt2Ny_K4CJvmOECzA?e=fhW9mQ
Here's an idea: Since the DynamicCameraLimits script seem to be the root of the problem... Maybe the min/max settings of GameCamera2D could be hooked up to the edge markers and there would be no need for DynamicCameraLimits at all. That would make such a great addition to the out-of-the-box offering of AC.
This has been the last thing I haven't been able to get AC to handle, I would so love a solution to this.
Thanks a bunch!
But the camera there is also going beyond the limits of the background. So long as the camera doesn't go past the edge marker, it should be OK.
I've thought of that as well, but it's problematic to know what the camera's edge positions will be in advance of it actually being there. I shall give it some more thought, though.
Yes, but this is not that unusual. This happens pretty much anytime anyone with a really wide screen monitor (which are getting more common) plays one of these games. We pad with black borders to make up for this, but the markers would have to be where they are on the repro in order to work right for less wide screen ratios.
If only the foreground elements would stay put at the screen limits rather than moving "inside" the screen it would be fine, but as it is, people are reporting broken off pieces of foreground floating across the screen.
Well, I really appreciate you looking into this, as it stands I'm leaning towards non moving foregrounds since the results on wide screens are just super extreme.
You need only clamp the calculated float in LateUpdate. Here's one that does that, and also removes the need to define edge markers (provided the foreground element is already in the most extreme position):
This is experimental, and only works when using Orthographic projection, but give this a try:
Nice!
EdgeParallax works flawlessly! 👌
DynamicCameraLimits also works fine in my experiments though when I resize the game window in free aspect mode to narrow ratios I sometime get some of the area outside the limit marker in view. But I noticed that if I "refresh" it by switching player to one in a new scene and then back, everything looks perfect again. And I don't really need perfect results as typically people don't get to resize in-game anyway.
I noticed it still affects game objects with the Parallax2D component differently depending on the screen ratio, but that doesn't matter now that we can use EdgeParallax for objects that should be snapped to the edges!
Using the markers makes it easier to use than the previous version of DynamicCameraLimits too, will you be including these components in a release perhaps?
Thanks a bunch. I'll make sure to update my review of this asset with even more praise 👍