I had that same issue, what I ended up doing was adding a seperate variable called ShakeCFrame which the module changes, then multiplying that on top of the player input in the render step function
Lmao yeah about 5 hours of playing around later, I came to roughly the same solution
Is it possible to use the shake while the players cameraās cframe is being set to a location in a loop?
Iām making a cannon system where while your aiming your camera is stuck on the barrel and want to use this shake when fired. Thanks!
Nevermind, I can just pause the loop that sets the cameraās cframe while the shake happens.
perhaps to make those short bursts of movement blend smooth into each other, instead of random univariate noise which would have made them step-wise more likely
Are you willing to share the code for this?
it only works locally due to localscripts having the ability to access the camera
very nice to see unity assets imported to roblox.
I am having an issue where this script:
function CameraShaker:ShakeOnce(magnitude, roughness, fadeInTime, fadeOutTime, posInfluence, rotInfluence)
local shakeInstance = CameraShakeInstance.new(magnitude, roughness, fadeInTime, fadeOutTime)
shakeInstance.PositionInfluence = (typeof(posInfluence) == "Vector3" and posInfluence or defaultPosInfluence)
shakeInstance.RotationInfluence = (typeof(rotInfluence) == "Vector3" and rotInfluence or defaultRotInfluence)
self._camShakeInstances[#self._camShakeInstances + 1] = shakeInstance --this line has the error
return shakeInstance
end
returns the error āattempt to get length of a nil valueā even though I used a cameraShaker.new() and a CameraShakeObject:Start() function in the camera shake wrapper module script:
local CameraShaker = require(script:WaitForChild("CameraShaker"))
local CurrentCamera = workspace.CurrentCamera
local CamShake = CameraShaker.new(Enum.RenderPriority.Camera.Value, function(shakeCFrame)
CurrentCamera.CFrame *= shakeCFrame
end)
CamShake:Start()
Does anyone know how to solve this issue?
Nevermind, I solved it by changing the variable in the shaker wrapper module from the CameraShaker module to the camera shake object (CameraShaker.new() result)
Iām using this as part of a cutscene Iām making, so the camera is set to Scriptable. After the camera shakes, the cameraās cframe isnāt exactly where it originally was. Is there a way to counter this or would you just have to set the cameraās cframe again?
Is there a way to make the screen shake, but not offset your mouse position?
Do you put the scripts into server script service? Also do you call it in a local or server script. Anyone know?
Anyway to have this only affect the camera on one axis?
You need to call this on the client because only the client has an active camera.
Sorry for reviving, but is there a way i can make this work with tweens?
Hello! I have been trying to make a little camera shake for my game; here is the script I use:
local camerashaker = require(game.Players.LocalPlayer.PlayerScripts:WaitForChild("CameraShaker"))
local player = game.Players.LocalPlayer
repeat task.wait() until game:IsLoaded()
local char = player.Character
local hum = char:WaitForChild("Humanoid")
local camera = game.Workspace.CurrentCamera
local camShake = camerashaker.new(Enum.RenderPriority.Camera.Value, function(shakeCf)
camera.CFrame = camera.CFrame * shakeCf
end)
camShake:Start()
local iswalking = false
local previous = true
while task.wait() do
if hum.MoveDirection.Magnitude > 0 then
iswalking = true
else
iswalking = false
end
if previous ~= iswalking then
if iswalking == true then
print("walk")
camShake:StopSustained(0)
camShake:ShakeSustain(camerashaker.Presets.Earthquake)
end
if iswalking == false then
print("nowalk")
camShake:StopSustained(0)
camShake:ShakeSustain(camerashaker.Presets.HandheldCamera)
end
end
previous = iswalking
end
Whenever I run it, it prints normally, however the camera shake intensifies a whole lot the longer I wait in a certain mode. After 30 seconds on the HandheldCamera, it does 360s and 180s. I donāt know if this is intentional, and if it is, how to fix it. Any help appreciated!
Earthquake & Handheld Camera both have heavy like weight on the shake. If you go within the module and find a script that says presets you can choose the one you like which you could also modify. I suggest you dont use camera shakes for camera bobbing search up some videos on youtube for camera bobbing.