[Request] Camera Shake effect

Get help using Construct 2

Post » Thu Jan 22, 2015 9:30 am

Hello,

I don't know if the effect exist, but could it be possible to create a shader (or something), with customizable parameters, to simulate a camera shake 'of the screen' and not of the actual game camera (which is contraint by the level borders).

That way, we could do a camera shake even if the level fits one screen with the borders!
One way would be to copy and past the actual screen by a few pixels in every direction and filling the empty spaces with black color.

Or perhaps there's another way to achieve a camera shake inside a bordered one screen room (and without zoom tricks); I would love to know! :)
B
68
S
21
G
12
Posts: 314
Reputation: 12,011

Post » Thu Jan 22, 2015 10:04 am

Is the built-in shake aspect of the scroll to behavior not usable?

https://www.scirra.com/manual/102/scroll-to
If your vision so exceeds your ability, then look to something closer.
Moderator
B
129
S
29
G
77
Posts: 5,188
Reputation: 54,281

Post » Thu Jan 22, 2015 10:09 am

I believe KaMiZoTo is talking about overcoming the limitation of the built-in shake that requires some scrolling room for the shake to work (or enabling Unbounded scrolling).
B
19
S
6
G
6
Posts: 1,101
Reputation: 5,646

Post » Thu Jan 22, 2015 11:31 am

@zenox98 The built-in cam shake of the scroll to behavior doesn't work when your camera is against 2 or more borders of the layout. So if you create a 640x480 game room in a 640x480 layout, the cam shake is impossible.
B
68
S
21
G
12
Posts: 314
Reputation: 12,011

Post » Thu Jan 22, 2015 1:12 pm

You could add a global variable like I did 'g_Screenshake' with a default value of 0.
Then add the events like in this image. "Trigger once" when you want to activate the shake.
I'm using layout scale but you could tweak it to your needs of course! :)
You do not have the required permissions to view the files attached to this post.
B
83
S
20
G
6
Posts: 175
Reputation: 8,131

Post » Thu Jan 22, 2015 2:58 pm

+1. I could never figure out a decent way to pull this off aside from adding 1 row of extra tiles and stretching backgrounds outside of the level / viewport.

I suppose increasing the layout scale by 0.1 and then shaking would work, but some people might notice, and it'd look bad for low-resolution games.

Perhaps, if this shader were to be made, it could duplicate the outside rows of pixels starting from a certain point. So if you're using 16x16 tiles it'd be 16, giving the illusion that there is another row of tiles outside of the level. If you only duplicate the outside row of pixels then it'd look smeared.
Image
B
238
S
28
G
13
Posts: 1,787
Reputation: 18,485

Post » Thu Jan 22, 2015 3:21 pm

Have you tried magicam?
B
31
S
9
G
3
Posts: 491
Reputation: 3,988

Post » Thu Jan 22, 2015 3:59 pm

@Robin Sommer The problem with scaling shake is that its awful on a low resolution game set in low quality fullscreen. That's why I was wondering if there was another trick (without zoom) or a shader. :)

@Tokinsom As you said, scale is not adapted to low res game. :(

@alvarop I'm not 100% sure but I think I tried it and it had the same issue. I will try again to be certain.
EDIT: I've just tried it again. Same problem with borders (It can only shake thanks to the zoom deviation parameter. But if you set it to 0, no more shake...)
B
68
S
21
G
12
Posts: 314
Reputation: 12,011

Post » Fri Jan 23, 2015 5:09 pm

@KaMiZoTo If you're looking to code your own, I do it like this. Make sure your layout is set to Unbounded scrolling. Have a camera object that follows the player but clamp it's x,y coordinates to the layout size (essentially negating Unbounded scrolling). You can shake the screen by adding random values to the camera position and also add that random value to the clamped min, max.

The X position for the camera would be something like this: clamp(camera.x, layoutMinX+randomVariable, layoutMaxX+randomVariable)

You would have to bring the randomVariable back to 0 when done shaking the screen.
B
79
S
51
G
37
Posts: 365
Reputation: 23,695

Post » Sun Jan 25, 2015 8:09 am

Hi, all!

I have been trying to get into shaders - sometimes even with a little bit of success. And working on something else I noticed that (at least on my hardware) a shifted texture gets nicely "stretched out" near the boundaries. Sounds like a great way to shift a texture around its draw rectangle.

Put an effect like that on a layer and in the editor it is just shifted:
Image

But at runtime it's a different story:
Image

So then you can shift a value dynamically:
Image

And get some neat shake (looks much better at full speed):
Image

Or shift both values:
Image

...for a full-on earthquake:
Image

It takes "real" pixels as input, so if "Fullscreen scaling" is set to High quality the shifts will be based on the screen resolution, if set to low it will work "right"

Installation: Extract the c2addon and drag into an open C2 window.

Shift.zip


My skills are limited so I'm not sure if it could be made to shift everything below if placed on an upper level - but currently you can have parallax shaking, for example. I have kept things extra slim - so if the values are 0 it will still run (or perhaps automatically won't) - so please enable/disable the effect as needed.

It would be super-great if someone could test this with something real and say what the performance is like.
You do not have the required permissions to view the files attached to this post.
B
19
S
6
G
6
Posts: 1,101
Reputation: 5,646

Next

Return to How do I....?

Who is online

Users browsing this forum: imhotep22, semaso, StanBond and 10 guests

cron