### Basic Camera Shake Implementation in Lua Source: https://github.com/sleitnick/rbxcamerashaker/blob/master/README.md Demonstrates the fundamental usage of RbxCameraShaker to apply camera shake effects. It shows how to create a `CameraShaker` instance, start it, and apply preset shakes like 'Explosion' periodically. The `ShakeCamera` function is a placeholder for how the actual shake offset is applied to the camera's CFrame. ```lua 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 ``` -------------------------------- ### CameraShaker Object Methods in Lua Source: https://github.com/sleitnick/rbxcamerashaker/blob/master/README.md Lists the core object-oriented methods available on a `CameraShaker` instance in Lua. These methods control the lifecycle and application of camera shakes, including starting, stopping, applying single shakes, and initiating sustained shakes. ```lua camShaker:Start() camShaker:Stop() camShaker:StopSustained([fadeOutTime]) camShaker:Shake(shakeInstance) camShaker:ShakeSustain(shakeInstance) camShaker:ShakeOnce(magnitude, roughness [, fadeInTime, fadeOutTime, posInfluence, rotInfluence]) camShaker:StartShake(magnitude, roughness [, fadeInTime, posInfluence, rotInfluence]) ``` -------------------------------- ### CameraShaker:StartShake Source: https://context7.com/sleitnick/rbxcamerashaker/llms.txt Creates and starts a custom sustained shake effect with specified parameters. The shake continues until manually stopped with StartFadeOut. ```APIDOC ## CameraShaker:StartShake ### Description Creates and starts a custom sustained shake effect with specified parameters. Similar to ShakeOnce but the shake continues until manually stopped with StartFadeOut. ### Method `StartShake(magnitude, roughness, fadeInTime, positionInfluence?, rotationInfluence?) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **magnitude** (number) - Required - The intensity of the shake. - **roughness** (number) - Required - The frequency or choppiness of the shake. - **fadeInTime** (number) - Required - The duration in seconds for the shake to reach its full magnitude. - **positionInfluence** (Vector3) - Optional - A Vector3 defining the influence of the shake on the camera's position. Defaults to (0.1, 0.1, 0.1). - **rotationInfluence** (Vector3) - Optional - A Vector3 defining the influence of the shake on the camera's rotation. Defaults to (1, 0.5, 0.5). ### Request Example ```lua local customShake = camShake:StartShake(2, 3, 1) local posInfluence = Vector3.new(0.1, 0.1, 0.1) local rotInfluence = Vector3.new(1, 0.5, 0.5) local ambientShake = camShake:StartShake(0.5, 0.5, 2, posInfluence, rotInfluence) ``` ### Response #### Success Response (200) Returns a `CameraShakeInstance` object representing the started shake. #### Response Example ```lua -- The returned value is a CameraShakeInstance object, not a JSON response. -- Example usage: customShake:StartFadeOut(2) ``` ``` -------------------------------- ### Start Custom Sustained Camera Shake Source: https://context7.com/sleitnick/rbxcamerashaker/llms.txt Creates and starts a custom sustained camera shake effect. This method allows for fine-grained control over shake magnitude, roughness, and fade-in time, with optional influence vectors for position and rotation. The shake continues until manually stopped. ```lua local CameraShaker = require(game.ReplicatedStorage.CameraShaker) local camera = workspace.CurrentCamera local camShake = CameraShaker.new(Enum.RenderPriority.Camera.Value + 1, function(shakeCf) camera.CFrame = camera.CFrame * shakeCf end) camShake:Start() -- Start custom sustained shake: magnitude 2, roughness 3, fadeIn 1s local customShake = camShake:StartShake(2, 3, 1) -- With custom influence vectors local posInfluence = Vector3.new(0.1, 0.1, 0.1) local rotInfluence = Vector3.new(1, 0.5, 0.5) local ambientShake = camShake:StartShake(0.5, 0.5, 2, posInfluence, rotInfluence) -- Stop the shake after some time wait(10) customShake:StartFadeOut(2) ``` -------------------------------- ### CameraShakeInstance API: Constructor and Static Fields in Lua Source: https://github.com/sleitnick/rbxcamerashaker/blob/master/README.md Shows the Lua code for the `CameraShakeInstance` class, including its static fields representing shake states and its constructor. The constructor takes parameters for magnitude, roughness, and fade times. ```lua CameraShakeInstance.CameraShakeState - FadingIn - FadingOut - Sustained - Inactive instance = CameraShakeInstance.new(magnitude, roughness, fadeInTime, fadeOutTime) ``` -------------------------------- ### CameraShaker API: Constructor and Static Fields in Lua Source: https://github.com/sleitnick/rbxcamerashaker/blob/master/README.md Provides the Lua code for accessing static fields and the constructor of the `CameraShaker` class. `CameraShakeInstance` and `Presets` are static fields, while `CameraShaker.new()` is used to create a new instance, requiring a render priority and a bind function. ```lua CameraShaker.CameraShakeInstance CameraShaker.Presets CameraShaker.new(renderPriority, bindFunction) ``` -------------------------------- ### Initialize CameraShaker Instance in Lua Source: https://context7.com/sleitnick/rbxcamerashaker/llms.txt Creates a new CameraShaker instance, binding it to the render loop to apply camera shake offsets. It requires a render priority and a callback function to process the shake CFrame. ```lua local CameraShaker = require(game.ReplicatedStorage.CameraShaker) local camera = workspace.CurrentCamera -- Create a CameraShaker instance local renderPriority = Enum.RenderPriority.Camera.Value + 1 local camShake = CameraShaker.new(renderPriority, function(shakeCf) -- Apply shake offset to camera -- playerCFrame is your base camera position camera.CFrame = playerCFrame * shakeCf end) -- Start the shaker (binds to render loop) camShake:Start() ``` -------------------------------- ### Create Custom Camera Shake Instance Source: https://context7.com/sleitnick/rbxcamerashaker/llms.txt Allows the creation of a custom camera shake instance with full control over shake parameters like magnitude, roughness, fade-in, and fade-out times. It also supports custom influence vectors for position and rotation, and provides methods to check the shake state. ```lua local CameraShaker = require(game.ReplicatedStorage.CameraShaker) local CameraShakeInstance = CameraShaker.CameraShakeInstance local camera = workspace.CurrentCamera local camShake = CameraShaker.new(Enum.RenderPriority.Camera.Value + 1, function(shakeCf) camera.CFrame = camera.CFrame * shakeCf end) camShake:Start() -- Create custom shake instance: magnitude 4, roughness 8, fadeIn 0.5s, fadeOut 2s local customInstance = CameraShakeInstance.new(4, 8, 0.5, 2) customInstance.PositionInfluence = Vector3.new(0.2, 0.2, 0.2) customInstance.RotationInfluence = Vector3.new(2, 1, 1) -- Apply the custom instance camShake:Shake(customInstance) -- Check shake state local state = customInstance:GetState() -- States: CameraShakeInstance.CameraShakeState.FadingIn, FadingOut, Sustained, Inactive print("Is shaking:", customInstance:IsShaking()) print("Is fading in:", customInstance:IsFadingIn()) print("Is fading out:", customInstance:IsFadingOut()) ``` -------------------------------- ### CameraShaker.Presets Source: https://context7.com/sleitnick/rbxcamerashaker/llms.txt Built-in preset configurations for common camera shake scenarios. Each preset returns a properly configured CameraShakeInstance ready for use. ```APIDOC ## CameraShaker.Presets ### Description Built-in preset configurations for common camera shake scenarios. Each preset returns a properly configured CameraShakeInstance ready for use. ### Method Access presets via `CameraShaker.Presets.` ### Parameters None ### Request Example ```lua -- One-shot presets (use with :Shake()) camShake:Shake(CameraShaker.Presets.Bump) camShake:Shake(CameraShaker.Presets.Explosion) -- Sustained presets (use with :ShakeSustain()) camShake:ShakeSustain(CameraShaker.Presets.Earthquake) camShake:ShakeSustain(CameraShaker.Presets.HandheldCamera) ``` ### Response #### Success Response (200) Each preset returns a `CameraShakeInstance` object configured according to the preset's parameters. #### Response Example ```lua -- The returned value is a CameraShakeInstance object, not a JSON response. -- Example usage: local bumpShake = CameraShaker.Presets.Bump camShake:Shake(bumpShake) ``` ### Available Presets - **Bump**: Short impact, ideal for collisions. - **Explosion**: Intense shake for explosions. - **Earthquake**: Sustained rumbling effect. - **BadTrip**: Disorienting sustained effect. - **HandheldCamera**: Realistic camera movement. - **Vibration**: Machinery or engine vibration. - **RoughDriving**: Vehicle movement shake. ``` -------------------------------- ### Utilize Camera Shaker Presets Source: https://context7.com/sleitnick/rbxcamerashaker/llms.txt Provides access to built-in preset configurations for common camera shake scenarios. Each preset returns a configured CameraShakeInstance that can be used with :Shake() for one-shot effects or :ShakeSustain() for continuous effects. ```lua local CameraShaker = require(game.ReplicatedStorage.CameraShaker) local camera = workspace.CurrentCamera local camShake = CameraShaker.new(Enum.RenderPriority.Camera.Value + 1, function(shakeCf) camera.CFrame = camera.CFrame * shakeCf end) camShake:Start() -- One-shot presets (use with :Shake()) camShake:Shake(CameraShaker.Presets.Bump) -- High magnitude, short, smooth camShake:Shake(CameraShaker.Presets.Explosion) -- Intense and rough -- Sustained presets (use with :ShakeSustain()) camShake:ShakeSustain(CameraShaker.Presets.Earthquake) -- Continuous, rough camShake:ShakeSustain(CameraShaker.Presets.BadTrip) -- High magnitude, low roughness camShake:ShakeSustain(CameraShaker.Presets.HandheldCamera) -- Subtle, slow camShake:ShakeSustain(CameraShaker.Presets.Vibration) -- Rough, low magnitude camShake:ShakeSustain(CameraShaker.Presets.RoughDriving) -- Medium roughness/magnitude -- Available presets: -- Bump - Short impact, ideal for collisions -- Explosion - Intense shake for explosions -- Earthquake - Sustained rumbling effect -- BadTrip - Disorienting sustained effect -- HandheldCamera - Realistic camera movement -- Vibration - Machinery or engine vibration -- RoughDriving - Vehicle movement shake ``` -------------------------------- ### CameraShakeInstance.new Source: https://context7.com/sleitnick/rbxcamerashaker/llms.txt Creates a custom camera shake instance with full control over shake parameters. Used internally by presets but can be used directly for advanced customization. ```APIDOC ## CameraShakeInstance.new ### Description Creates a custom camera shake instance with full control over shake parameters. Used internally by presets but can be used directly for advanced customization. ### Method `CameraShakeInstance.new(magnitude, roughness, fadeInTime, fadeOutTime) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **magnitude** (number) - Required - The intensity of the shake. - **roughness** (number) - Required - The frequency or choppiness of the shake. - **fadeInTime** (number) - Required - The duration in seconds for the shake to reach its full magnitude. - **fadeOutTime** (number) - Required - The duration in seconds for the shake to fade out. ### Request Example ```lua local customInstance = CameraShakeInstance.new(4, 8, 0.5, 2) customInstance.PositionInfluence = Vector3.new(0.2, 0.2, 0.2) customInstance.RotationInfluence = Vector3.new(2, 1, 1) camShake:Shake(customInstance) ``` ### Response #### Success Response (200) Returns a `CameraShakeInstance` object configured with the provided parameters. #### Response Example ```lua -- The returned value is a CameraShakeInstance object, not a JSON response. -- Example usage: print(customInstance:IsShaking()) ``` ``` -------------------------------- ### Create Custom One-Shot Camera Shake in Lua Source: https://context7.com/sleitnick/rbxcamerashaker/llms.txt Generates and applies a custom one-shot camera shake effect with fine-grained control over magnitude, roughness, fade times, and positional/rotational influence. This method allows for unique shake behaviors without relying on presets. ```lua local CameraShaker = require(game.ReplicatedStorage.CameraShaker) local camera = workspace.CurrentCamera local camShake = CameraShaker.new(Enum.RenderPriority.Camera.Value + 1, function(shakeCf) camera.CFrame = camera.CFrame * shakeCf end) camShake:Start() -- Custom shake: magnitude 3, roughness 1, fadeIn 0.2s, fadeOut 1.5s camShake:ShakeOnce(3, 1, 0.2, 1.5) -- Custom shake with position and rotation influence local posInfluence = Vector3.new(0.25, 0.25, 0.25) local rotInfluence = Vector3.new(2, 1, 1) camShake:ShakeOnce(5, 10, 0, 2, posInfluence, rotInfluence) -- Light shake for footsteps camShake:ShakeOnce(0.5, 5, 0, 0.3) -- Heavy impact shake camShake:ShakeOnce(8, 15, 0.1, 1) ``` -------------------------------- ### CameraShakeInstance Object Methods in Lua Source: https://github.com/sleitnick/rbxcamerashaker/blob/master/README.md Details the methods available for manipulating a `CameraShakeInstance` object in Lua. These methods allow for updating the shake effect, controlling fade transitions, and querying the current state of the shake. ```lua instance:UpdateShake(deltaTime) instance:StartFadeOut(fadeOutTime) instance:StartFadeIn(fadeInTime) instance:IsShaking() instance:IsFadingOut() instance:IsFadingIn() instance:GetState() ``` -------------------------------- ### Trigger One-Shot Camera Shake in Lua Source: https://context7.com/sleitnick/rbxcamerashaker/llms.txt Applies a one-shot camera shake effect using predefined presets like 'Explosion' or 'Bump'. The shake plays once and fades out automatically. The function returns the shake instance for potential manual control. ```lua local CameraShaker = require(game.ReplicatedStorage.CameraShaker) local camera = workspace.CurrentCamera local camShake = CameraShaker.new(Enum.RenderPriority.Camera.Value + 1, function(shakeCf) camera.CFrame = camera.CFrame * shakeCf end) camShake:Start() -- Trigger explosion shake when something explodes local function onExplosion() camShake:Shake(CameraShaker.Presets.Explosion) end -- Trigger bump shake on collision local function onCollision() camShake:Shake(CameraShaker.Presets.Bump) end -- Example: shake every 5 seconds while true do wait(5) camShake:Shake(CameraShaker.Presets.Explosion) end ``` -------------------------------- ### Apply and Stop Sustained Camera Shake in Lua Source: https://context7.com/sleitnick/rbxcamerashaker/llms.txt Initiates a continuous camera shake effect, such as for earthquakes or driving, that persists until stopped. It returns a shake instance that can be used to fade out specific sustained shakes or stop all sustained shakes. ```lua local CameraShaker = require(game.ReplicatedStorage.CameraShaker) local camera = workspace.CurrentCamera local camShake = CameraShaker.new(Enum.RenderPriority.Camera.Value + 1, function(shakeCf) camera.CFrame = camera.CFrame * shakeCf end) camShake:Start() -- Start earthquake effect when player enters danger zone local earthquakeShake = camShake:ShakeSustain(CameraShaker.Presets.Earthquake) -- Later, stop just this specific shake with 1 second fadeout wait(5) earthquakeShake:StartFadeOut(1) -- Or start driving shake when player enters vehicle local drivingShake = camShake:ShakeSustain(CameraShaker.Presets.RoughDriving) -- Stop all sustained shakes at once with 2 second fadeout camShake:StopSustained(2) ``` -------------------------------- ### Stop Camera Shakes Source: https://context7.com/sleitnick/rbxcamerashaker/llms.txt Provides methods to halt camera shake effects. StopSustained fades out all active sustained shakes with a specified duration, while keeping the shaker running. Stop() completely unbinds the shaker from the render loop. ```lua local CameraShaker = require(game.ReplicatedStorage.CameraShaker) local camera = workspace.CurrentCamera local camShake = CameraShaker.new(Enum.RenderPriority.Camera.Value + 1, function(shakeCf) camera.CFrame = camera.CFrame * shakeCf end) camShake:Start() -- Start multiple sustained shakes camShake:ShakeSustain(CameraShaker.Presets.Earthquake) camShake:ShakeSustain(CameraShaker.Presets.HandheldCamera) -- Stop all sustained shakes with 1 second fadeout (keeps shaker running) camShake:StopSustained(1) -- Or completely stop the camera shaker (unbinds from render loop) camShake:Stop() -- Can restart later camShake:Start() ``` -------------------------------- ### CameraShaker:Stop and CameraShaker:StopSustained Source: https://context7.com/sleitnick/rbxcamerashaker/llms.txt Stop methods to halt camera shake effects. Stop() unbinds the shaker from the render loop entirely. StopSustained() fades out all active sustained shakes while keeping the shaker running. ```APIDOC ## CameraShaker:Stop and CameraShaker:StopSustained ### Description Stop methods to halt camera shake effects. Stop() unbinds the shaker from the render loop entirely. StopSustained() fades out all active sustained shakes while keeping the shaker running. ### Method `StopSustained(fadeOutTime?) `Stop()` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **fadeOutTime** (number) - Optional - The duration in seconds for sustained shakes to fade out. Defaults to 1 second if not provided. ### Request Example ```lua -- Stop all sustained shakes with 1 second fadeout (keeps shaker running) camShake:StopSustained(1) -- Or completely stop the camera shaker (unbinds from render loop) camShake:Stop() ``` ### Response #### Success Response (200) These methods do not return a value, they modify the state of the CameraShaker. #### Response Example None ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.