[Request] Camera Shake effect

Get help using Construct 2

Post » Sun Jan 25, 2015 1:12 pm

@SomeBody Hey nice! That's what I'm seeking. :)
It works pretty well!
I'm wondering if there's a way to add the same sort of parameters as the C2 shake has (duration/Constant or Reducing). May be there's simple action formulas to do that. (that's not my cup of tea to be honest :( )

And yes, the result is not the same in low quality. It visually doubles the shift. Perhaps you can divide by 2 the X and Y shift parameter if you detect low quality (but I don't know if you can do that in fact!). We still can create an event to do that easely.

I don't know about the performance. My computer is quite powerful so we should test that on low spec machines.

Anyway this is promising! :)


PS: If you have a shader on a layer 'MyShaders' and you want it to be applied to all below layers, there's a trick. Add on your layer 'MyShaders' a mask shader like for example the 'Noise mask'. Put it on top and set to 0. TAADDAAAAAA !
B
72
S
21
G
12
Posts: 314
Reputation: 12,111

Post » Sun Jan 25, 2015 1:30 pm

@KaMiZoTo - Duration and such - shaders are "stupid" in a way, as far as I can tell, they don't get to keep anything between draw cycles. So you are better off using variables, which should be easy.

Something like:
If ShakeScreen > 0
Layer - Shift FX enabled,
Set parameter to random(-ShakeScreen,Shakescreen),
Shakescreen - subtract dt

With a little more work, of course.

I could make a version that works with %, not pixels, but having pixels lets us have precision movement for something like this:
Image

Anyhow, hopefully some smart people help me fix some small problems in the other thread (effects-by-somebody-adjust-hsb-trim-shift-dissolve_t123401) and we'll have a useful shader.
B
19
S
6
G
6
Posts: 1,101
Reputation: 5,646

Post » Mon Jan 26, 2015 1:11 am

@UberLou Thank you for that tips. I will try that if I have issues with the shader. :)
B
72
S
21
G
12
Posts: 314
Reputation: 12,111

Post » Mon Jan 26, 2015 4:22 am

@Somebody

Seems like a very cheap effect. Awesome too. 8-)

I dropped it into my current mobile project and set it to modulate every tick. FPS was the same as without it. My android device is lower end, so I'd say you're looking good with this one.
Don't lose your work. Backup your game with Dropbox.
B
44
S
10
G
10
Posts: 1,106
Reputation: 9,202

Post » Mon Jan 26, 2015 6:59 am

@TiAm - cool, glad to hear that. I tested it on some reasonably high-res desktop stuff, but knowing it seems ok on mobile is great.
B
19
S
6
G
6
Posts: 1,101
Reputation: 5,646

Post » Sun Feb 08, 2015 11:51 pm

@Somebody, I agree with kamizoto on the duration statement. It shouldn't be uber hard to add another extra parameter where we can input a time measure - a simple "screenshake every X seconds" parameter.

Currently I'm using a Function for this since I kinda despise variables =P http://i.imgur.com/vIKICqQ.png
I'm no programmer so my logic sucks, but if you add that 3rd parameter, I can get rid of the Function "object".
B
33
S
9
G
1
Posts: 156
Reputation: 3,034

Post » Mon Feb 09, 2015 8:30 am

notnsane wrote:@Somebody, I agree with kamizoto on the duration statement. It shouldn't be uber hard to add another extra parameter where we can input a time measure - a simple "screenshake every X seconds" parameter.

Currently I'm using a Function for this since I kinda despise variables =P http://i.imgur.com/vIKICqQ.png
I'm no programmer so my logic sucks, but if you add that 3rd parameter, I can get rid of the Function "object".


Well, as mentioned above Shaders don't remember variables and such - most that could be done would be making a separate shaking Shader with just one parameter - strength.
B
19
S
6
G
6
Posts: 1,101
Reputation: 5,646

Post » Mon Feb 09, 2015 12:02 pm

Ah, I see. Well, then current iteration is fine =)
B
33
S
9
G
1
Posts: 156
Reputation: 3,034

Post » Sun Feb 07, 2016 12:29 pm

Somebody wrote: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 are a genius! :shock: , works perfect, thaaaaanks!!
B
5
S
2
G
1
Posts: 17
Reputation: 573

Post » Tue Aug 16, 2016 4:33 pm

Robin Sommer wrote: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! :)


I don't have enough reputation to pm you, sry)
I just wanted to thank you for this advice - it was just the thing i needed for my game.
Months pass on, but you still help people ( who know how to use forum search ) out there!
B
12
S
1
Posts: 24
Reputation: 611

PreviousNext

Return to How do I....?

Who is online

Users browsing this forum: StefanSava, zenox98 and 59 guests