Thoughts on 2D Player Camera Movement

Hello All,

My current goal is to make a small 2D Fighter with 6 - 8 players divided into teams who battle on a small, stationary map. Due to the map’s smaller size, the camera is fixed in on a brick’s location to keep focus on all the players. Due to this, player movement is restricted to left and right limits of what is shown on the screen.

The issue I have would be that one player’s screen resolution could be 2560 x 1080 where as another player’s may be 1280 x 720. In reality only a small portion from the lower resolution screen would be inaccessible to the player, but not seeing someone could reveal a weakness in a player’s view, and cause an unfair advantage since there are ranged attacks in-game.

Both screenshots below show my character to the far right, but only the highest resolution screen shows my character:

1980 x 1080


vs.
480 x 320


This caused me to create a camera that moves with the player so that this is not a problem, but a potential nitpick would be that a player may not want that type of aesthetic to their gaming experience.

https://gyazo.com/7e2656e94d8a8e0d6590071c267b6d5f

Not sure why the controls are inverted, lol.

In reality, I am, “torn inbetween the two” (Latoya Luckett, Torn) on whether I should do one or the other, or add a third option to switch between both with a press of a single button while in-game.

At the end of the day, I want the player to feel like they have control of how their camera works, so what do y’all think?

  • Stationary Camera
  • Moving Camera
  • Both

0 voters

1 Like

I personally prefer a moving camera. However, the Y value should be locked. Whenever the player jumps (which I feel is a lot in games like these), the camera shouldn’t move up with them, as it can be quite obnoxious.

1 Like

what is up with those mobile controls? My game did the same thing.

How did you line up the walls with the edge of the camera? I’ve done something similar, but on some screen sizes (depending on the physical size of the users monitor) it would not line up correctly by a lot of studs.

Does yours account for all monitor sizes?

Looks great!

I actually did not line up the walls with the edge of the camera due to it giving players with bigger screens an advantage.

I just set up a limit via math.clamp to both sides of the camera part to set the limit of where the character can go so that everyone’s left and right limits are equal.

@K_reex I was thinking this as well, but the issue might come up where multiple platforms of different heights would be (slightly) out of view of the player. However, I did set a small limit on how far up the camera will go as well, so the camera will only really move up on a scale equal to one jump.

1 Like

Can you explain this a bit more? How does the script align the exact edge of the screen to where the character hits a “wall”? Is it consistent on other screen sizes?

Although having both could be considered, I honestly do not think sacrificing fairness (this is a PvP game, so it’s important that it should be fair and balanced) and giving those with a larger screen an upper hand over those who have a smaller screen for some visual aesthetic, so I think a moving camera would work best.

However, if you really want to have the stationary camera, I would suggest moving the camera back for smaller devices to that they could see the rest of the map, compensating for their small screen size. (Basically, smaller devices have the camera more zoomed out so they can still see the whole map, although this could introduce the problem of being hard to see on small devices, so).

1 Like

I agree. The entire reason for this post was to find a way to work around there being a stationary camera in the case that camera type would fit better. I do not accept noticeable advantages. I am not sure why I did not think of pushing the camera back, but I am sure it is the same reason for the game looking smaller on an already small screen. That might just have to be something I will have to deal with.

Can you explain this a bit more? How does the script align the exact edge of the screen to where the character hits a “wall”? Is it consistent on other screen sizes?

@Hazania For the most part, it is not consisted. I attempted this with the smallest screen possible, and like what is shown in the above post for one of the smallest mobile devices, the character is right outside of view, but he is close. Say the typical map is 80 studs from left to right. Since the camera location is in the middle, that would leave me with 40 studs left to right. Since the player should only move inbetween this range, I use this:

player.Humanoid:MoveTo( Vector3.new( math.clamp( player.HumanoidRootPart.Position.X, Cam.Position.X - 40, Cam.Position.X + 40 ),  player.HumanoidRootPart.Position.Y,  ground.Position.Z) )

Since this is the width of the average map, has decent mobility for players, and has size also viewable on smaller mobile devices, this are the numbers I chose.

1 Like