How to create a first person locked effect without enabling it?

In my game the player is supposed to be first person, and be able to look around naturally. The Roblox “LockFirstPerson” property creates a pretty good version of that.

game.Players.LocalPlayer.CameraMode = Enum.CameraMode.LockFirstPerson

The problem arises from when I try to do a bobble effect. It is done by animating a part weilded to the head of the player and then renderstepping the camera to the part.

It seems that the Roblox property does something similar and so the gameplay will look like this (the file won’t upload for some reason so best way I can describe it is the 2 cameras constantly switching so it’s a seizure enducing experience).

The question is: What can be done to fix this? I have thought of 3 ways.

  1. Make a bobble effect in a different way (can’t find any method)
  2. Create a simulation of the first person locked camera that doesn’t mess witht he bobble
  3. Somehow let them both coexist without there being seizure experience.

This is the script


local Player = game.Players.LocalPlayer
local char = Player.Character

local human = char:WaitForChild("Humanoid")

local root = char:WaitForChild("HumanoidRootPart")

local Animation = (Instance.new("Animation",human))

local Animator = (human.Animator)

Animation.AnimationId = "rbxassetid://11496894057"

local run = human:LoadAnimation(Animation)

local uis = game:GetService("UserInputService")

--functions

uis.InputBegan:Connect(function(input)

	if input.UserInputType == Enum.UserInputType.Keyboard then
		if input.KeyCode == Enum.KeyCode.W then
			run:Play()

		end
	end
end)

uis.InputEnded:Connect(function(input)

	if input.UserInputType == Enum.UserInputType.Keyboard then
		if input.KeyCode == Enum.KeyCode.W then
			run:Stop()

		end
	end
end)

game:GetService("RunService").RenderStepped:Connect(function()
	game.Workspace.CurrentCamera.CFrame = char.Head.CFrame
end)
1 Like

If I’m not mistaken using the .Subject property of the Camera should help emulate the effect you’re looking for. Also, make sure you’re setting the Camera as Scriptable!

Let me know if you need any more help or you work anything out! :wink:

1 Like

how would one use “subject” property in this case?
I can’t find anything about it.

1 Like

Writing a new line of code containing something like ‘Camera.Subject = BasePart’ should work if I’m not mistaken.

1 Like

“Subject is not a valid member of Workspace.Camera”

Surely you can just go to StarterPlayer, and change the CameraMaxZoomDistance to 0.5.

this still causes the same seizure issue, however it is less extreme this time

1 Like

use workspace.CurrentCamera instead

same error “Subject is not a valid member of Workspace.CurrentCamera”

its CameraSubject
ghdhahhrbfchdhshebgnjc

1 Like

It no longer gives seizure, but now the camera can’t turn :sweat_smile:
image
I inserted it in the renderstepped, although it seems to give the same result outside of it.

well how the camera for roblox characters are controlled is through the humanoid

the humanoid controls how it works and required that the CameraSubject is the humanoid otherwise it wont manage it

so without the humanoid managing the camera the camera wont turn

either make your own camera controller or allow the humanoid to manage it

would I have to do something like this for the camera then, to make it turn?

local function Update()

camera.CameraType = Enum.CameraType.Scriptable

local x = (math.abs((mouse.X/mouse.ViewSizeX)) - 0.5)/1.5 * 0.5 + math.noise(workspace.DistributedGameTime/4, workspace.DistributedGameTime/4, 500)/5
local y = (math.abs((mouse.Y/mouse.ViewSizeY) - 1) - 0.5)/3 * 0.5 + math.noise(workspace.DistributedGameTime/4, workspace.DistributedGameTime/4, 500)/5
local z = math.noise(workspace.DistributedGameTime/4, workspace.DistributedGameTime/4, 750)/5

local cframe = camera.CFrame:Lerp(CFrame.new(camera_cframe.Position, camera_cframe.Position + camera_cframe.LookVector + Vector3.new(x, y - 0.05, z)), 0.2 * 1)
camera.CFrame = CFrame.new(camera_cframe.Position, camera_cframe.Position + cframe.LookVector)

end

local run = RunService.RenderStepped:Connect(Update)`

(I fear that it will just glitch out again and give seizure).