Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/Sleitnick/RbxCameraShaker
Camera shake effects for Roblox games
https://github.com/Sleitnick/RbxCameraShaker
Last synced: 5 days ago
JSON representation
Camera shake effects for Roblox games
- Host: GitHub
- URL: https://github.com/Sleitnick/RbxCameraShaker
- Owner: Sleitnick
- License: mit
- Created: 2019-09-28T16:43:25.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2023-07-06T19:14:27.000Z (over 1 year ago)
- Last Synced: 2024-11-02T05:02:46.588Z (12 days ago)
- Language: Lua
- Homepage:
- Size: 18.6 KB
- Stars: 78
- Watchers: 4
- Forks: 17
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-roblox - RbxCameraShaker - Camera shake effects. (Modules / Camera Shake)
README
# RbxCameraShaker
RbxCameraShaker is a port of the free Unity3D [EZ Camera Shake](https://assetstore.unity.com/packages/tools/camera/ez-camera-shake-33148) 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](https://www.roblox.com/library/1461025953/Camera-Shaker).
## 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:
```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
```## API
### CameraShaker
**Static Fields:**
```lua
CameraShaker.CameraShakeInstance
CameraShaker.Presets
```**Constructor:**
```lua
camShaker = CameraShaker.new(renderPriority, bindFunction)
```**Object Methods:**
| Method | Description |
| ------ | ----------- |
| `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:**
```lua
CameraShakeInstance.CameraShakeState
- FadingIn
- FadingOut
- Sustained
- Inactive
```**Constructor:**
```lua
instance = CameraShakeInstance.new(magnitude, roughness, fadeInTime, fadeOutTime)
```**Object Methods:**
| Method | Description |
| ------ | ----------- |
| `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
| Preset | Description | Ideal Type |
| ------ | ----------- | ---------- |
| Bump | A high-magnitude, short, yet smooth shake | Once |
| Explosion | An intense & rough shake | Once |
| Earthquake | Continuous, rough shake | Sustained |
| BadTrip | Bizarre shake with high magnitude & low roughness | Sustained |
| HandheldCamera | A subtle, slow shake | Sustained |
| Vibration | Rough but low magnitude | Sustained |
| RoughDriving | Slightly rough and medium magnitude | Sustained |These presets are easy to modify and use. For an example of using one of the presets, look at the Basic Use section.