Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
2

[Repost] Help with camera manipulation?

Asked by 6 years ago

I'm trying to get the camera to follow the mouse.

https://vimeo.com/266586757 -- I'm very close but its kind of weird because the speed changes and doesn't really stay on track with the mouse.

https://vimeo.com/266512080 -- part invis

I'm assuming that it has something to do with my delta (change in pos)




------------------------------------------------ local Player = game.Players.LocalPlayer local move_vector = Vector3.new(0,0,0) local speed = .001 local scroll_speed = 6 local mouse = game.Players.LocalPlayer:GetMouse() local lastx, lasty = mouse.X, mouse.Y local userInput = game:GetService("UserInputService") local runService = game:GetService("RunService") local focus = Instance.new("Part") focus.Anchored = true focus.CanCollide = false focus.Transparency = 1 focus.Size = Vector3.new(0.1,0.1,0.1) focus.Position = Vector3.new(0,2,0) focus.Parent = Player focus.Name = "Focus" local function Panned(input, processed) if not processed and input.UserInputType == Enum.UserInputType.MouseMovement then local delta = input.Delta if userInput.MouseBehavior ~= Enum.MouseBehavior.LockCenter then -- If locked, then calculate delta: delta = Vector2.new(mouse.X - lastx, mouse.Y - lasty) end lastx, lasty = mouse.X, mouse.Y panDeltaMouse = delta end end ------------------------------------------------ userInput.InputChanged:Connect(function(input,processed) if input.UserInputType == Enum.UserInputType.MouseMovement and MouseButton then Panned(input,processed) move_vector = move_vector+Vector3.new(panDeltaMouse.X,0,panDeltaMouse.Y) print("Moving to: ",move_vector) end end) ------------------------------------------------ game:GetService("RunService").RenderStepped:Connect(function() focus.Position = focus.Position + (move_vector)*speed end)

1 answer

Log in to vote
0
Answered by 5 years ago

the camera acts weirldy unless you say that you want to control the camera

game.Workspace.CurrentCamera.CameraType = Enum.CameraType.Scriptable
Ad

Answer this question