How Do I Apply Camera Shake When An ACS Gun Is Shot?

  1. What do you want to achieve? I want to make a system so camera shake will be applied when I shoot an ACS gun.

  2. What is the issue? I straight up can’t even think on how to do it, There’s no tutorial and I see many custom ACS games use it; Yet normal 2.0.1 ACS doesn’t have it!

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

Looked everywhere, even Youtube. I cannot find anything

2 Likes

heres the solution that came to my mind
basically: just tell the client that your specific gun was fired through a remoteEvent so it can apply a camera offset

localscript:

local camera = workspace.CurrentCamera
local camerashake = 0

local runService = game:GetService("RunService")

local player = game.Players.LocalPlayer
local character = player.Character

local shaking = false
local ShakeEvent = game.ReplicatedStorage.Events.ScreenShake
local StopShakingEvent = game.ReplicatedStorage.Events.EndScreenShake

ShakeEvent.OnClientEvent:Connect(function(shake)
	shaking = true
	camerashake = shake
end)
StopShakingEvent.OnClientEvent:Connect(function()
	shaking = false
	character:FindFirstChildOfClass("Humanoid").CameraOffset = Vector3.new(0,0,0)
end)

runService.RenderStepped:Connect(function()
	if shaking == true then
		local currentTime = tick()

		local bobbleX = math.cos(currentTime * camerashake) --* .25
		local bobbleY = math.abs(math.sin(currentTime * camerashake)) --* .25        

		local bobble = Vector3.new(bobbleX+math.random(-1,1), bobbleY+math.random(-1,1), 0)
		character:FindFirstChildOfClass("Humanoid").CameraOffset = bobble
	end
end)


although this is meant to cover MUCH MUCH MUCH broader things than a gun being fired, and i honestly wrote it last year so it kind of sucks

and whatever you do: dont copy and paste this for your guns firing, because runservice will constantly redo the script, its really more of an example on how to actually offset the camera than anything else

unless you’re asking for recoil, which is just a completely separate thing

3 Likes

As a newbie it’s hard to understand what you’re saying here, If it’s meant for broader things than a gun being fired; then why use it?

Also, recoil already comes in ACS. Definitely not recoil

i understand that saying “broader things” was a pretty vague term

what i really mean by “broader things” are events that should have camerashake apply to EVERY player (ex: a meteor striking the map)

while gun camerashake should really only apply to the person shooting, if thats what you’re looking for

1 Like

If this is meant for more than 1 person, then how do I make it only happen for 1 person?

if youd want it to shake everyone’s camera, just fire every client instead of just the client that shot the gun.

1 Like

You didn’t take too many beers, right?
I thought it fired for all clients, and asked how to make it only happen for 1 person haha!
:smile:

ok well what i coded was meant for everyone, but you can take

local currentTime = tick()

		local bobbleX = math.cos(currentTime * camerashake) --* .25
		local bobbleY = math.abs(math.sin(currentTime * camerashake)) --* .25        

		local bobble = Vector3.new(bobbleX+math.random(-1,1), bobbleY+math.random(-1,1), 0)
		character:FindFirstChildOfClass("Humanoid").CameraOffset = bobble

and through a remoteEvent, you could bobble the camera offset once by alot, and then tween the offset back to 0,0

specifically, when your gun activates, you could activate said remoteEvent and target it towards the client whose gun activated, and then do the camerashake magic from there

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.