im making a 2d game where if you move your mouse to the edgy of the screen your camera will go with it and stops until the players character is on the other side of the edgy
the way im making this is calculate the mid point position of the mouse and the humanoidrootpart constantly every frame and set the camera cframe to the mid point of those positions(humanoid root part and mouse position)
so far i have had no luck making this work the game either just dont update the mouse position constantly and just returns the same position over and over or its a mouse.hit function that returns a position when you press the mouse which doesnt help at all
this is the code i used
local Camera = workspace.Camera
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Mouse = require(ReplicatedStorage:WaitForChild("Mouse"))
local MousePosition = Mouse.GetPosition()
Camera.FieldOfView = 1
local HumanoidRootPart = script.Parent.HumanoidRootPart
local RunService = game:GetService("RunService")
RunService.RenderStepped:Connect(function()
Camera.CFrame = HumanoidRootPart.CFrame + Vector3.new(0,0,3000)
print(MousePosition)
end)
plus me not having very much experience with the mouse doesnt help at all

3 comments
This is just a suggestion (I don’t know if it will work) but maybe have a part that goes to the mouses the position in the 3d workspace, and then the camera set on that part.
i thought of that but i was like i still have to get the mouse position in 3d space which is what im having a problem with
I’ve edited