GameMaker Issues With Split-Screen and Changing Viewports

G

George Bohorquez

Guest
Hello! I'm having an issue trying to get split-screen to work for my project. As it stands, the following information denotes some of the numbers put into place for Viewport 0:

Camera Properties
XPos = 0
YPos = 0
Width = 512
Height = 384

Viewport Properties
XPos = 0
YPos = 0
Width = 1024
Height = 768

Object Following : Obj_Player_1
HBor = 260
VBor = 192

These settings are there by default when only one player is on screen. For enabling split-screen, I've put the following into Viewport 1:

Camera Properties
XPos = 256
YPos = 0
Width = 256
Height = 384

Viewport Properties
XPos = 512
YPos = 0
Width = 512
Height = 768

Object Following : Obj_Player_2
HBor = 260
VBor = 192

Now, Viewport 1 is not visible right off the bat. Instead, I've opted into writing some code that will make the viewport visible if the game recognizes that there is a second player in the game.

Along with this activation, I put down some code that would adjust the original viewport, Viewport 0, to adapt to such changes:


Code:
global.PlayerCount = 2;

if (global.PlayerCount = 2)
    {
        view_set_visible(1, true);
        
        camera_set_view_border(0, 130, 192);
        camera_set_view_size(0, 256, 384);
        view_set_wport(0, view_wport[0] / 2);
    }

The unfortunate thing about this method is that it tends to squish the left side of the screen, the Player 1 side (Viewport 0), distorting the images all the same.

When the values of change are inputted directly into the Viewport menu however, everything works out fine. No distortion in the image. It seems to be an issue more so with the code, specifically with the "view_set_wport()" function.

Does anyone know a way that I can fix this? I've tried to provide as much information as I can.
 
Top