N
ndaoud360
Guest
I have looked everywhere and none seem to work. How can I get the screen to shake when I press for example "space" My view is following the character which is why none of the ones I found work.
view_xview = clamp(x - (view_wview div 2), 0, room_width - view_wview);
view_yview = clamp(y - (view_hview div 2), 0, room_height - view_hview);
I just tried manually following the character and still didn't work.Either you make the view manually follow the character using this in the end step event:
and apply the shake code afterwards.Code:view_xview = clamp(x - (view_wview div 2), 0, room_width - view_wview); view_yview = clamp(y - (view_hview div 2), 0, room_height - view_hview);
Or you apply the shake effect in the begin draw event (if multiple views are used, this can have a different effect).
Yea I tried something similar and while it worked, whenever the player is following the view the shake wont happen.I think a nice way to have camera shake and other nice effect like panning, easy "real time cut-scene" and such stuff is to have camera object. And then you make your view follow the cam, not the player.
With that cam you can have alot of fun, you make it follow the player, you change its X and Y position with a random and create screen shake, etc.
Here is my screen shake code.Anyhow it entirely depends on your code. If it didn't work its not because it wasn't a good way to do it, its because there's something wrong about your code or stuff you didn't think through.
If you want to go more in-depth, I'd invite you to share people your related code.
shakeIntensity = 0;
if (shakeIntensity > 0)
{
view_xview[0] += choose(random(shakeIntensity), random(-shakeIntensity));
view_yview[0] += choose(random(shakeIntensity), random(-shakeIntensity));
}
shakeIntensity -= 10;
alarm[1] = 0.2 * room_speed;
shakeIntensity = 10;
alarm[1] = 0.2 * room_speed;
view_visible[1]=1;
view_xview[1]=view_xview[0]+(irandom(amount)-amount/2);
view_yview[1]=view_yview[0]+(irandom(amount)-amount/2);
view_visible[1]=0;
Thanks this actually worked but the shaking doesn't stop. Should I create an alarm to make it stop?Hi! I used to have the same problem as you, and found a solution.
In obj_shake:
Create event
Step eventCode:view_visible[1]=1;
Destroy eventCode:view_xview[1]=view_xview[0]+(irandom(amount)-amount/2); view_yview[1]=view_yview[0]+(irandom(amount)-amount/2);
View[1] should not follow the player, and have same size as View[0]Code:view_visible[1]=0;
I later created an obj_camera to follow the player, so I stopped using this method (should've done it from the start...)
thank you!!! i had the same problem and implemented a solution similar to yours. it was quite frustrating for awhile, so thank you for your help!Hi! I used to have the same problem as you, and found a solution.
In obj_shake:
Create event
Step eventCode:view_visible[1]=1;
Destroy eventCode:view_xview[1]=view_xview[0]+(irandom(amount)-amount/2); view_yview[1]=view_yview[0]+(irandom(amount)-amount/2);
View[1] should not follow the player, and have same size as View[0]Code:view_visible[1]=0;
I later created an obj_camera to follow the player, so I stopped using this method (should've done it from the start...)
Easiest Screenshake EVER!!!!I have looked everywhere and none seem to work. How can I get the screen to shake when I press for example "space" My view is following the character which is why none of the ones I found work.
/// Camera Target
target_ = o_player; // Camera target, (What camera will be following)
/// Screen Shake Amount
min_amount_ = 1; // Min Screen Shake
max_amount_ = 10; // Max Screen Shake
/// Screen Shake On or Off
screen_shake_ = false; // Screen Shake On or Off?
/// If Screen Shake is True, DO SCREEN SHAKE
if (screen_shake_ == true) {
x = target_.x+random_range(min_amount_, max_amount_)
y = target_.y+random_range(min_amount_, max_amount_)
}