GG Camera Shake - "Screenshake that doesn't suck"

GG Camera Shake - "Screenshake that doesn't suck"

Original Unity Code by GasGiant Under MIT License

Recently, when I was looking for a good camera shaker option that actually looked good for guns, I came across GasGiant’s video on camera shake. This led me to discover their oh so beautiful camera shake- that looks way cleaner than any other camera shaker that I could find. Thus, I have now ported it to Roblox for usage in my games and the public.


Why This?

  • Easy to use.
  • Three shake algorithms (Kick, Perlin, and Bounce) for all your use cases.
  • Handles strength and direction of the shake depending on position of the shake source.
  • Adjusting camera shake strength for player accessibility (with an option to remain unchanged for recoil/fair play).
  • Presets for 3D and 2D environments to start you off.
  • Easy customization.
  • Strictly typed.

Example Code:

Using Presets:

local Shaker = require(path.to.GGCameraShaker)
Shaker.Shake(Shaker.Presets.Explosion3D(...))

Presets can accept arguments, so you only have to make one generalized preset instead of multiple similar presets.

Without Presets:

local Shaker = require(path.to.GGCameraShaker)
Shaker.Shake(Shaker.PerlinShake.New(...))

Choose between KickShake, BounceShake, PerlinShake, or make your own custom shake algorithm.

Note:

All arguments are completely optional for both scenarios. If you pass through no arguments it will default to default parameters. More detailed documentation on Github linked below.


Download & Resources


Preview

Recoil Preview

Explosion Preview w/ Falloff

Directional Shake Based on Source Position.

I recommend just testing for yourself in the test place provided, since I couldn’t record the greatest previews with the 10MB upload limit.


Credits

GasGiant for the open-sourced code under MIT License. Their repo and video here. I highly recommend you give the video a watch, as it just shows how well thought out his camera shake is:

SwiftCast for providing the test place, I just implemented the shake there because I was too lazy to create my own test place. So, credits to SwiftCast (thanks for saving my time, lol).

For those looking for the script lines I added/modified for the camerashake inside this test place:

  • RocketLauncher.LocalScript Line 117, 43, 44, 45, 48 and 9.
  • StarterPlayerScripts Line 57 and 7.
16 Likes

Does it do what EZCameraShake does?, , for example if i only want to shake the camera position in x,y,z but not rotation, would i need to use ShortShake2D?

Also the module is pretty good

1 Like

Yeah, it just has more features and I feel like it looks better, too (especially for implementing gun recoil). As for only position shakes, yup you just use the 2D preset.

1 Like

Does whatever the shake function is have a “3D Origin” parameter by any chance? For example when you want the camera to shake from an explosion, but you’d want more impact in the side of the explosion the camera is closer to, if that makes sense.

Yeah, it’s the sourcePosition parameter, and to configure the falloff rate you just edit the attenuation values.

1 Like

v1.1.0 Summary
-Assigned ICameraShake type to .New() to prevent strict type redlining on .Shake()
-Added a function for disabling/enabling camera shakes
-Removed template benchmarking module that I accidentally put in the .rbxm
-Added an option to force camera shakes for a shake instance if camera shakes are disabled (for something like gun recoil).

Also updated documentation on Github.

1 Like

v1.1.1 Summary

  • Fixed disabling camera shake issues with camera drift.
  • Added a forcedEnable argument that is true by default for the GunFire3D preset.

[BACKWARDS INCOMPATIBLE CHANGES]

  • Change:
    FalloffDegree parameter is now a number instead of a string literal. Marginal speed increase, too, with the addition of fast paths in power evaluate.
  • Reason:
    Straying a bit from the original C# code with enums, but I think this system will be a bit more clear than literals, with falloff degrees not limited to integers.
  • Fix:
    If you have been using the default params or presets then you’re fine, this will only impact your code if you have passed through falloffDegree in any function arguments. Simply change them to their corresponding number values.

Not really any major addition so I didn’t change the major versioning despite backwards incompatible changes. If you encounter any bugs/issues just let me know, and I’ll try to resolve them quickly (especially with Wally, I haven’t used it before, so I don’t know if I have set it up properly).

1 Like

v1.1.2 Summary

  • Removed redundant lines in disable camera shake, which also fixed resuming shakes after disabling and enabling shakes.
  • Added a SetStrengthScale() function for extra customizability. This multiplier (previously just a toggle) is intended for the player to be able to edit for the implementation of accessibility settings.
  • Removed IsEnabled bool in place of strength multiplier. Disabling/enabling functions will set that value to 0/1. Merely an internal change; pre-existing scripts will remain unaffected.
  • ForcedEnabled active shake instances (for gun recoil, or stuff that players can’t disable for reasons of fair play) will remain unaffected by the strength multiplier.
1 Like

v1.1.3 Summary

  • Small type improvement for GetOffset().
  • KickShake .New() overload argument improved and also made optional.
  • Improved comments in main camera shaker module.
  • Main CameraShaker module now returns all utility modules for ease of use and negligible performance cost. E.g. using Shaker.KickShake.New() instead of requiring KickShake separately.

Just the usual QOL additions that I’ll be adding whenever I encounter inconveniences. Also, the Github documentation was significantly improved to be a lot more detailed.

possible to add the luau code on github and publish to wally?

1 Like

Just did and I believe all Wally issues should be resolved.