Enum.RenderPriority.Camera.Value effects movement

  1. I want to keep player camera control and on top of it add camera shake effects

For camera shake I use EZ camera shake module

What i mean by camera control:
robloxapp-20231010-1927053.wmv (1.1 MB)

  1. The issue I face is that camera shake effects player movement
    In the video I all the time press ā€œSā€ key
    robloxapp-20231010-1919069.wmv (3.3 MB)

  2. Scripts
    for camera control:

local Player = game:GetService("Players").LocalPlayer	
Player.CharacterAppearanceLoaded:Wait()
local player = game.Players.LocalPlayer
local mouse = Player:GetMouse()
local camera = workspace.CurrentCamera
local runService = game:GetService("RunService")
local screenGui = game.StarterGui.ScreenGui

local Distance = Vector3.new(0,25,0)
local Direction = Vector3.new(0,-1,0)
local CameraSensitivity = 5


function getMouseScreenPositionCentered() 
	return Vector2.new(
		mouse.X - screenGui.AbsoluteSize.X/2,
		mouse.Y - screenGui.AbsoluteSize.Y/2)
end

function pixelToFraction(pixelV2)
	return pixelV2 / screenGui.AbsoluteSize
end


function onRenderStep() 	
	if player.Character then
		local rootPart = player.Character.HumanoidRootPart
		local playerposition = player.Character.HumanoidRootPart.Position + Vector3.new(0,0,3)

		local cameraoffset = Distance + playerposition

		local mouseScreenPos = pixelToFraction( getMouseScreenPositionCentered() )
		local Axis = Vector3.new(-mouseScreenPos.Y,0,mouseScreenPos.X)

		local cameraPos = cameraoffset + Axis * CameraSensitivity 

		camera.CFrame = CFrame.new(cameraPos, cameraPos + Direction)
	end
end

runService:BindToRenderStep("Camera", Enum.RenderPriority.Camera.Value, onRenderStep)

Script that starts camera shake:

local CameraShaker = require(game.ReplicatedStorage.CameraShaker)

local Player = game:GetService("Players").LocalPlayer	
Player.CharacterAppearanceLoaded:Wait()
local camera = workspace.CurrentCamera

local camShake = CameraShaker.new(Enum.RenderPriority.Camera.Value, function(shakeCf)
	camera.CFrame = camera.CFrame * shakeCf
end)

camShake:Start()

game.ReplicatedStorage.Player_Events.Cam_Shake.OnClientEvent:Connect(function(Type)
	if Type == "Explosion" then
		print(Enum.RenderPriority.Camera.Value)
		camShake:Shake(camShake.Presets.BadTrip)
	end

end)

Thanks in advance!

1 Like

Maybe somone know the solution?