[Request] Camera Shake effect

0 favourites
From the Asset Store
Simple and easily editable template for a dynamic camera that zooms in and out based on how far apart the players are.
  • 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!

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

    https://www.scirra.com/manual/102/scroll-to

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

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

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

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

  • Have you tried magicam?

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

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

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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:1jbq4wlb][/attachment:1jbq4wlb]

    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.

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

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

    Anyhow, hopefully some smart people help me fix some small problems in the other thread () and we'll have a useful shader.

  • UberLou Thank you for that tips. I will try that if I have issues with the shader.

  • Somebody

    Seems like a very cheap effect. Awesome too.

    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.

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

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