[Update]
(Added OffsetCFrame PresetParameter to both Still and Wobble presets, read through the PresetParams section below for details)
Hi
Are you frustrated at trying to get the camera to behave a certain way, or just annoyed at writing out tons of camera code in your scripts? Well this system should solve all of your concerns!
I have created a system here for the public that you may find really useful. It is an extremely simple camera manipulation system in one package that uses different presets to control the camera.
Letโs say you want to make the camera orbit around a part after you touch it.
Instead of having to write all that camera code out in one script, you can simply just call the module.
Wobble preset sneak peek:
https://gyazo.com/4c2ab41adfc91c203389a006811f3abc
(Running Wobble preset on default settings)
In any ๐๐จ๐๐๐ฅ ๐๐๐ซ๐ข๐ฉ๐ญ (๐ถ๐ต๐ณ๐ WORKS FROM LOCAL SCRIPTS)
Start by requiring the module script. This will return to the local script all of the functions in this script.
local CameraModule = require(workspace.EZCam)
After that, you will be able to run this module with ease.
This module has two functions:
CameraModule:Start()
and
CameraModule:Stop()
๐๐๐ฆ๐๐ซ๐๐๐จ๐๐ฎ๐ฅ๐:Start()
Arguments: (CFrameOrPositionOrInstance, PresetType, PresetParameters, Duration)
This function contains two optional arguments and two needed arguments.
The first two are the needed ones and the last two are optional. The first argument is the reference position/cframe/part (๐ช๐ญ๐๐๐๐๐ถ๐๐ท๐๐๐๐๐๐๐๐ถ๐๐ฐ๐๐๐๐๐๐๐).
Argument #1: CFrameOrPositionOrInstance
It has different uses depending on the preset - for example, using Vector3.new(0, 10, 0) as the first argument with the Orbit preset will cause the camera to orbit Vector3.new(0, 10, 0), and using CFrame.new(30, 0, 0) with the Still preset will cause the camera to change directly to the CFrame of CFrame.new(30, 0, 0). Lets say you want to move your camera to your characterโs headโs CFrame. What we would type is:
CameraModule:Start(MyCharacter.Head.CFrame, โStillโ)
This will move the camera to my headโs CFrame ONCE.
When the character walks away, the camera will stay where it was after it moved to the head.
If you want to camera to LOCK to the characterโs headโs cframe (continuously update to the headโs cframe), simply write the head itself:
CameraModule:Start(MyCharacter.Head, "Still")
When you put in an instance, it lets the module know that you want to lock the cameraโs cframe to that instance (update the cameraโs cframe to that object repeatedly) until stopped.
Lets say we want to keep locking to the characterโs headโs CFrame but make it look a little nicer with a different preset:
CameraModule:Start(MyCharacter.Head, "Wobble")
What this will do is lock the cameraโs CFrame to the head, but it will make it shake a little and give it a more realistic feel.
Argument #2: PresetType
The current usable presets in this version are:
Still
Wobble
LookAt
Orbit
Argument #3: PresetParameters
PresetParameters is basically just a way of saying customizable features.
Current PresetParameters for each Preset:
Still:
- OffsetCFrame โ If you want to Lock to a part but have the camera move to the part + an offset, use this parameter.
Wobble:
- OffsetCFrame โ If you want to Lock to a part but have the camera move to the part + an offset, use this parameter.
- WobbleSinSpeed โ How fast it vibrates using sin
- WobbleCosSpeed - How fast it vibrates using cos
- WobbleSinSize โ Total sin moving distance
- WobbleCosSize โ Total cos moving distance
LookAt:
- AnchorPoint โ The Position that the camera is in when it looks at the target
Orbit:
- OrbitSpeed โ How fast the orbit is around the subject
- OrbitHeight โ How high it orbits above the subject
- OrbitDistance โ How far it orbits from the subject
- IsReversed โ Determines if the rotation direction is reversed from the default rotation direction
Lets say that we have the camera currently orbiting around a part.
CameraModule:Start(workspace.MyPart, "Orbit")
What if we want to change the speed at which it rotates? Well, thankfully, there is a property called OrbitSpeed for the Orbit preset.
How we would go about changing the speed is to create a PresetParams variable. We will then make this the 3rd argument when calling the Start() function.
local PresetParameters = {
OrbitSpeed = 10;
}
CameraModule:Start(workspace.MyPart, "Orbit", PresetParameters)
Now, the orbit will be 10 times as fast as the default orbit.
Lets say we also want to make it rotate in the other direction.
We see that there is a method called IsReversed for the Orbit preset, so we are able to do this easily:
local PresetParameters = {
OrbitSpeed = 10;
IsReversed = true;
}
CameraModule:Start(workspace.MyPart, "Orbit", PresetParameters)
Now, the camera will orbit around the part 10 times as fast as default and the other direction from default.
Remember though, inside a table, you need to finish each line with either a semicolon ( ; ) or a comma ( , ) otherwise it will error (unless it is the last value).
local PresetParameters = {
OrbitSpeed = 10 -- bad
}
local PresetParameters = {
OrbitSpeed = 10; -- good
}
Argument #4: Duration
All what Duration does is after the amount of time (in seconds) has passed, it will move the camera back to its original position (your character).
Lets say we want to make the camera orbit a part, but after 5 seconds, the module stops and the camera returns to your character.
CameraModule:Start(workspace.MyPart, "Orbit", PresetParameters, 5)
And what if we want to add a duration but leave the PresetParameters argument blank?
Well, very easily we could just type:
CameraModule:Start(workspace.MyPart, "Orbit", nil, 5)
Typing nil or {} for the 3rd argument will ensure that everything is at its default settings.
Also, keep in mind that if you want it to never expire and go back to your character, just leave it blank or put -1.
๐๐๐ฆ๐๐ซ๐๐๐จ๐๐ฎ๐ฅ๐:๐๐ญ๐จ๐ฉ()
Arguments: None
This function is pretty self explanatory:
If any camera manipulation from this script is currently happening, it will stop it immediately and move your camera back to your character.
If we typed this:
CameraModule:Start(workspace.MyPart, "Orbit", PresetParameters, 5)
wait(2)
CameraModule:Stop()
it will stop after 2 seconds, regardless of the number 5 that we gave to it.
Example of How to Use Module:
(requiring the module and running Wobble effect) (these parameters make the camera move like an earthquake)
(Keep in mind, this camera is extremely new, so definitely let me know if you notice any bugs)
I will be making updates pretty frequently. Planned updates are more presets and more PresetParameters.
If you have any questions or concerns, feel free to ask.
If you use this to make any really cool or interesting projects, let me know!