Forest Logo
search
package_2

camera-shaker

By @lanred-dev

Roblox

Mirrored

RbxCameraShaker

RbxCameraShaker is a port of the free Unity3D EZ Camera Shake asset. The Unity3D asset had no licensing information, so I received written permission from the original authors of EZ Camera Shake to port their asset to Roblox.

This module is available from the Roblox library.

Purpose

RbxCameraShaker is a module that lets developers easily add realistic camera shake effects to Roblox games. The module is easy to use and performs well.

Basic Use

Simple example:

local function ShakeCamera(shakeCf)
	-- shakeCf: CFrame value that represents the offset to apply for shake effect.
	-- Apply the effect:
	camera.CFrame = camera.CFrame * shakeCf
end

-- Create CameraShaker instance:
local renderPriority = Enum.RenderPriority.Camera.Value + 1
local camShake = CameraShaker.new(renderPriority, ShakeCamera)

-- Start the instance:
camShake:Start()

-- Apply explosion shakes every 5 seconds:
while (true) do
	wait(5)
	camShake:Shake(CameraShaker.Presets.Explosion)
end

API

CameraShaker

Static Fields:

CameraShaker.CameraShakeInstance
CameraShaker.Presets

Constructor:

camShaker = CameraShaker.new(renderPriority, bindFunction)

Object Methods:

MethodDescription
camShaker:Start()Start the camera shaker
camShaker:Stop()Stop the camera shaker
camShaker:StopSustained([fadeOutTime])Stop all sustained shakes
camShaker:Shake(shakeInstance)Apply the shake effect once
camShaker:ShakeSustain(shakeInstance)Apply the shake effect coninuously
camShaker:ShakeOnce(magnitude, roughness [, fadeInTime, fadeOutTime, posInfluence, rotInfluence])Apply the custom shake effect once
camShaker:StartShake(magnitude, roughness [, fadeInTime, posInfluence, rotInfluence])Apply the custom shake effect continuously

CameraShakeInstance

This is mostly used internally, but is still exposed for use.

Static Fields:

CameraShakeInstance.CameraShakeState
  - FadingIn
  - FadingOut
  - Sustained
  - Inactive

Constructor:

instance = CameraShakeInstance.new(magnitude, roughness, fadeInTime, fadeOutTime)

Object Methods:

MethodDescription
instance:UpdateShake(deltaTime)Update the shake
instance:StartFadeOut(fadeOutTime)Fade out effect
instance:StartFadeIn(fadeInTime)Fade in effect
instance:IsShaking() Returns true if shaking
instance:IsFadingOut()Returns true if fading out
instance:IsFadingIn()Returns true if fading in
instance:GetState()Returns the current CameraShakeState

CameraShakePresets

PresetDescriptionIdeal Type
BumpA high-magnitude, short, yet smooth shakeOnce
ExplosionAn intense & rough shakeOnce
EarthquakeContinuous, rough shakeSustained
BadTripBizarre shake with high magnitude & low roughnessSustained
HandheldCameraA subtle, slow shakeSustained
VibrationRough but low magnitudeSustained
RoughDrivingSlightly rough and medium magnitudeSustained

These presets are easy to modify and use. For an example of using one of the presets, look at the Basic Use section.

Package Details

Install command (Click to copy)


Version

1.0.2

License

MIT

check_circle

Safe for commercial use

infoLicense identified from the packaged LICENSE file; the manifest declared none.

Automated license review — not legal advice.