I have managed to script a camera in the position of the GoPro Cam which is located beside the helmet. The results were great, but when I walk around my character decides to walk off the direction that I want to go.
The Results: When the player is idle, it will act like this: https://gyazo.com/14eaf75f99641672342f7da2a22afbee
The Issue:
-
But when I walk around, you can see I had to use shift lock to force my character to look at the direction of the mouse while I walk. I was unable to figure out how to solve this issue: https://gyazo.com/5399594e67ec62eb6e08211461e00c93
-
Secondly, I was unable to figure out how to pan around smoothly. My ugly solution was to add wait to slow down a bit and add MouseClick to avoid static movement: https://gyazo.com/20384e6c1ad797628ee3fa0c5016d542
The Code for Camera Pan
local M = plr:GetMouse()
local char = plr.Character
local root = char.HumanoidRootPart
local CharNeck = char:FindFirstChild("Neck", true)
local yOffset = CharNeck.C0.Y
local mouse = plr:GetMouse()
M.Move:connect(function()
if SetFocus == true then
CharNeck.C0 = CFrame.new(0, yOffset, 0) *CFrame.Angles(3 * math.pi/2, 0, math.pi) *CFrame.Angles(-math.asin(mouse.hit.lookVector.y),0,-math.asin(mouse.hit.lookVector.x))
root.CFrame = CFrame.new(root.CFrame.p,root.CFrame.p + Vector3.new(mouse.hit.lookVector.x,0,mouse.hit.lookVector.z))
end
wait(0.02)
end)
M.Button1Down:connect(function()
SetFocus = true
end)
M.Button1Up:connect(function()
SetFocus = false
end)
I would greatly appreciate your help.