• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Parallax Layer for Split Screen Multiplayer?

S

Suhaib

Guest
My game consists of multiple players in a split-screen setting. I created a parallax layer effect in separate objects, thinking the effect will work for each player, however, it only follows one player.

Is it possible to create a parallax layer for multiple viewports and players?

Thanks in advance!
 

Relic

Member
I’d say you would have to manually draw the each parallax layer for each view, working out the position of the layer based on the current player/view.

Have the controller object that is currently in charge of the parallax code perform its calculation in its draw event (if not already) but check which view is being rendered.

If view 0 then layer x = Player1.x //your parallax code
Else if view 1 then layer x= player2.x
Draw layer

I’m not 100% the draw event is called for each view- not tried multiple views before. But surely it must for it to be rendered twice...

edit: the manual says it does!
 
K

Kpax00

Guest
If I understand correctly I had a similar issue with my project. What I did was in a camera object, in the "Draw Begin" event use view_current to find out what view you are in. Depending on what view (example, player 1 may be view 0, player 2 may be view 1, etc) you're in, I moved what i wanted to into place. The "Draw Begin" event runs at the start of each view being drawn so for each view, you can move everything so it looks good for just that player. Does that make sense?
 
S

Suhaib

Guest
Thanks for the help, but I attempted to do both suggestions and there is still no separate parallax layers for all players, in fact there is no effect at all as I attempted to create the effect in the draw event.
 

Relic

Member
Kpax00 solutions sounds simpler as you do not need to worry about order of layers/instance controlling this effect.

Show your code for further assistance.
 
S

Suhaib

Guest
This is my code, I wrote it in the Draw Begin event:

if (view_current == 0){
layer_x("Backgrounds_7", obj_player.x /4);
layer_x("Backgrounds_8", obj_player.x /3);
layer_x("Backgrounds_9", obj_player.x /2);
layer_x("Backgrounds_10", obj_player.x /1);
}
 

Relic

Member
That’s only for one view? What about view1? Is your 2nd player a different object or is it also an instance of obj_player?

You need to repeat this code for if view_current=1 and you need to use obj_player2.x or whatever the 2nd player object is.
 
S

Suhaib

Guest
I repeated the code in the same draw event, but there is still no effect for either players
 
S

Suhaib

Guest
I got it, sorry everyone, I went full stupid. My mistake was putting the code in a separate object (obj_camera), I put the code in the actual players' draw event.

Thanks!
 

LeonDr

Member
I got it, sorry everyone, I went full stupid. My mistake was putting the code in a separate object (obj_camera), I put the code in the actual players' draw event.

Thanks!
For me it worked on the players' "Draw Begin" event
 
Top