Hey guys, I'm in the process of adding to this 2d movement system roblox has supplied to us via the Roblox Wiki (Source: http://wiki.roblox.com/index.php?title=Making_a_2D_Platformer)

This problem, now instead of being with the controls as in my previous question, is with the camera.

I've edited the system so the camera will follow the player on moving left as well as on moving right, The standalone LocalScript only had the camera tracking movement to the right so I balanced it by changing ;

if cameraX - cameraXChase < playerX then
			camera.CoordinateFrame = camera.CoordinateFrame + Vector3.new(cameraSpeed, 0, 0)
		end
	end
end

to;

if cameraX - cameraXChase < playerX then
			camera.CoordinateFrame = camera.CoordinateFrame + Vector3.new(cameraSpeed, 0, 0)
		elseif cameraX +cameraXChase >playerX then
			camera.CoordinateFrame = camera.CoordinateFrame - Vector3.new(cameraSpeed,0, 0)
		end
	end
end

Now this solution worked HOWEVER There's now a extremely noticeable 'shaky-cam' effect whenever the player Idles(Stops moving/Isn't moving)

Here's my updated version of the full Script so you can trial it in studio to see exactly what i'm talking about and if there's a way you can find a fix for it, I've found no solution so far and it's really annoying me;

local cameraHeight = 15
local cameraZOffset = 20
local cameraXChase = 10
local cameraSpeed = .25

local camera = game.Workspace.CurrentCamera
local player = game.Players.LocalPlayer
local RunService = game:GetService('RunService')

local function setupCamera()
	camera.CoordinateFrame = CFrame.new(Vector3.new(0,cameraHeight,cameraZOffset), Vector3.new(0,cameraHeight,0))
end
setupCamera()
player.CharacterAdded:connect(setupCamera)

local function onUpdate()
	if player.Character and player.Character:FindFirstChild('Torso') then
		local playerX = player.Character.Torso.Position.X
		local cameraX = camera.CoordinateFrame.p.X
		
		if cameraX - cameraXChase < playerX then
			camera.CoordinateFrame = camera.CoordinateFrame + Vector3.new(cameraSpeed, 0, 0)
		elseif cameraX +cameraXChase >playerX then
			camera.CoordinateFrame = camera.CoordinateFrame - Vector3.new(cameraSpeed,0, 0)
		end
	end
end

RunService:BindToRenderStep('Camera', Enum.RenderPriority.Camera.Value, onUpdate)

Like before, any help ASAP would be much appreciated! :)

Update: Link to testing area is https://www.roblox.com/games/415465424/Test-place as requested.

2 comments

0

Would you please provide a link to the test place?