Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Can someone help me with camera stuff?

I'm creating a custom physics engine (Because it'd be easier to manipulate stuff in my own physics engine), and it all works fine, but when you go into first person perspective, the fake character (That i'm using for my engine) glitches, I'm currently using the mouse, so the part it's focused on, faces the mouse, it works, but it glitches if you go into first person perspective, and since the engine is for an fps-like game, I need it to look towards where you're looking at in FPS mode (except up/down).

I currently use this in a loop : local cf=Vector3.new(mouse.Hit.p.x,fakePlayer.CFrame.p.y,mouse.Hit.p.z)

then, when I want it to point at the mouse : fakePlayer.CFrame=CFrame.new(fakePlayer.CFrame.p,cf)

It works, but in FPS mode, it glitches out a bit... alot. Anybody have any suggestions on how to fix this?

If you need the loop code, here it is :

while wait() do
	local mouse=game:service'Players'.localPlayer:GetMouse()
	local cf=Vector3.new(mouse.Hit.p.x,fakePlayer.CFrame.p.y,mouse.Hit.p.z)
	if Keys["w"] then
		fakePlayer.CFrame=CFrame.new(fakePlayer.CFrame.p,cf)*CFrame.new(0,0,-1)
	end
	if Keys["a"] then
		fakePlayer.CFrame=CFrame.new(fakePlayer.CFrame.p,cf)*CFrame.new(-1,0,0)
	end
	if Keys["s"] then
		fakePlayer.CFrame=CFrame.new(fakePlayer.CFrame.p,cf)*CFrame.new(0,0,1)
	end
	if Keys["d"] then
		fakePlayer.CFrame=CFrame.new(fakePlayer.CFrame.p,cf)*CFrame.new(1,0,0)
	end
	if Keys["spacebar"] then
		if fakePlayer.Falling.Value==false and Jumping==false and fakePlayer and fakePlayer:findFirstChild"PhysicsScript" then
			fakePlayer.Falling.Value=true
			Jumping=true
			fakePlayer:findFirstChild"PhysicsScript".Disabled=true
			for i = 0, 1, .1 do
				local hitroof, posroof = rayCast(fakePlayer.Position, (CFrame.new(fakePlayer.Position, fakePlayer.Position + Vector3.new(0, 2, 0))).lookVector, 1, fakePlayer)
				if not hitroof then
					fakePlayer.CFrame=fakePlayer.CFrame*CFrame.new(0, .5, 0)
					wait()
				else
					break
				end
			end
			fakePlayer:findFirstChild"PhysicsScript".Disabled=false
			Jumping=false
		end
	end
end

1 answer

It should be,

fakePlayer:FindFirstChild("PhysicsScript").Disabled = false--not fakePlayer:findFirstChild"PhysicsScript".Disabled=false

You need to change all your find first child's.

Hope this helps, if it does, accept my answer, it gives us both rep!

1 comment

0

No, that isn't the problem, it works fine, I use it on all my scripts and it works, ;p, it's the fact that when I'm in first person camera mode, it doesn't work

This discussion is preserved as it was. New answers, comments, and votes are closed.