[Request] Camera Shake effect

0 favourites
From the Asset Store
2D Tile Set
$1.20 USD
60% off
Tile map for your 2d platformer games, custom sets available on request
  • 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".

  • 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.

  • Ah, I see. Well, then current iteration is fine =)

  • 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:

    But at runtime it's a different story:

    So then you can shift a value dynamically:

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

    Or shift both values:

    ...for a full-on earthquake:

    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.

    [attachment=0:3nwkjfal][/attachment:3nwkjfal]

    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! , works perfect, thaaaaanks!!

  • 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!

  • Somebody I'm having troubles setting this up. Tried all different steps here and none of them is doing the shake for me.

  • 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".

    I'm using your events and they won't work for me. Any idea what could be wrong?

  • Smileh: Are you sure your Layout "Unbounded scrolling" property is set to "Yes" ?

  • Smileh: Are you sure your Layout "Unbounded scrolling" property is set to "Yes" ?

    This is supposed to be an alternative to use unbounded scrolling as far as I know. Otherwise we would just use the scroll to behaviour shake.

    Maybe I'm all wrong but Kamizoto refered me to this thread regarding shaking without unbounded scrolling

  • Smileh This shader effect is not related to bounded or unbounded scrolling. It's a fullscreen effect, whatever is on screen.

    Here is a simple Capx to show you how it works.:

    https://dl.dropboxusercontent.com/u/13847313/Scirra/ShakeCamExample.capx

    You will see a ShakeEffect layer. You can use a layer like this for all your fullscreen fx.

    In order to affect all the other layers behind this one, I use a trick. I include as first shader fx on it a NoiseMask (set at 0). After this one, you can add the fullscreen shaders you want.

    The important thing to know is to be sure you have at least ONE object (whatever it is) on this layer. (or the shader won't be applied)

    I hope it will help. I'm not good at explaining things. ^^

  • Smileh This shader effect is not related to bounded or unbounded scrolling. It's a fullscreen effect, whatever is on screen.

    Here is a simple Capx to show you how it works.:

    https://dl.dropboxusercontent.com/u/13847313/Scirra/ShakeCamExample.capx

    You will see a ShakeEffect layer. You can use a layer like this for all your fullscreen fx.

    In order to affect all the other layers behind this one, I use a trick. I include as first shader fx on it a NoiseMask (set at 0). After this one, you can add the fullscreen shaders you want.

    The important thing to know is to be sure you have at least ONE object (whatever it is) on this layer. (or the shader won't be applied)

    I hope it will help. I'm not good at explaining things. ^^

    Something might be real wrong because that capx is not even working for me. Spacebar ain't working for the shake. Tried switching to another key or trigger by a different event, just not working or my browser is real bugged. Not sure

  • Nevermind. Just figgured out it was Chrome. Tried on Edge and works. That explains why I couldn't make it work yesterday either. I was starting to think that I was dumb as a rock and it was my browser lol

    KaMiZoTo Btw I apply it to the layout not the layer and I don't have to use the noisemask trick. I guess you doing it on a layer because it causes some trouble to have it applie to the whole layout in your game? Would love to understand the reasoning why not applying to layout.

  • Smileh I use a layer because I don't want my fullscreen fx to affect the HUD for example.

  • Smileh I use a layer because I don't want my fullscreen fx to affect the HUD for example.

    Thanks for the help!

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Good thing you got it sorted, because I can't even remember how I did that, lol =P

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)