Screen shake effect in two-player split screen

So I've tried a couple different screen shake scripts and they work just fine in my game in single player - that is, when there's just one single view that follows the player, but if i try to modify it to fit the two-player mode, it just doesn't work. (that is, when there is two views following two different players) The shake effect always does some crazy tricks like throws the other player's view to god knows where or smth of the sort.

The code I'm currently using:

Create:
alarm[0] = 10;

Alarm 0:
view_xview[0] = 0;
view_yview[0] = 0;
instance_destroy();

Step:
view_xview[0] = random_range(-2,2);
view_yview[0] = random_range(-2,2);

So in two-player mode, I try to put both player's views there, as in:

Step:

view_xview[0] = random_range(-2,2);
view_yview[0] = random_range(-2,2);
view_xview[1] = random_range(-2,2);
view_yview[1] = random_range(-2,2);

Alarm 0:
view_xview[0] = 0;
view_yview[0] = 0;
view_xview[1] = 0;
view_yview[1] = 0;
instance_destroy();

But it goes into a mess. Other screen shake effect scripts have provided me a similar outcome if I've tried to modify it into following two views instead of one, it messes up the views completely in some way.
The views are always following the player objects in the rooms if that matters.
Any help?
thanks beforehand
 

trentallain

Member
So I've tried a couple different screen shake scripts and they work just fine in my game in single player - that is, when there's just one single view that follows the player, but if i try to modify it to fit the two-player mode, it just doesn't work. (that is, when there is two views following two different players) The shake effect always does some crazy tricks like throws the other player's view to god knows where or smth of the sort.

The code I'm currently using:

Create:
alarm[0] = 10;

Alarm 0:
view_xview[0] = 0;
view_yview[0] = 0;
instance_destroy();

Step:
view_xview[0] = random_range(-2,2);
view_yview[0] = random_range(-2,2);

So in two-player mode, I try to put both player's views there, as in:

Step:

view_xview[0] = random_range(-2,2);
view_yview[0] = random_range(-2,2);
view_xview[1] = random_range(-2,2);
view_yview[1] = random_range(-2,2);

Alarm 0:
view_xview[0] = 0;
view_yview[0] = 0;
view_xview[1] = 0;
view_yview[1] = 0;
instance_destroy();

But it goes into a mess. Other screen shake effect scripts have provided me a similar outcome if I've tried to modify it into following two views instead of one, it messes up the views completely in some way.
The views are always following the player objects in the rooms if that matters.
Any help?
thanks beforehand
When you shake the screen, you should be adding +2 or -2 instead of setting the view to that position. And then when you reset the view, you set it to (0, 0) instead of your players' (X, Y).

You might also need some new variables that you can update with your views' coordinates so you don't have it setting the view to the player every step.
 
When you shake the screen, you should be adding +2 or -2 instead of setting the view to that position. And then when you reset the view, you set it to (0, 0) instead of your players' (X, Y).

You might also need some new variables that you can update with your views' coordinates so you don't have it setting the view to the player every step.
ah makes sense, resetting the view to my player objects coordinates instead... I'll check if this change already will do difference
Thanks for response!
 
Top