I’m currently trying to replicate a “custom mouse” type of position, however, I’ve faced several problems because I don’t know exactly how to start. I even tried, but I have no idea how to really make this accurate and “elegant”, in other words, playable.
Currently: Watch Camera | Streamable
As you can see in this video, the circle (which is the custom mouse) is centered and does not move, but this is also because the mouse behavior is locked in the center. But I’m trying to find a solution to make it like these references: (Look carefully at the circle)
As you can see, the position of the circle is exactly centered in a specific position, which only makes the camera point to the last movement (position) of this circle.
If anyone has a solution, that would be great. I would have a code, but it’s no use, since it doesn’t work the way it’s supposed to work.
This is the module I made for personal use of the “custom mouse”:
--[[ Constructor ]]--
function CustomMouse.new(Root: BasePart): Constructor
local self = setmetatable({}, CustomMouse)
self.Primary = Root
self.Hit = CFrame.new(Root.Position + Vector3.new(0, 0, RAY_EXTEND))
self.X = 0
self.Y = 0
self:Start()
return self
end
--[[ Private Methods ]]--
function CustomMouse:_Update(Delta: Vector3): ()
UserInputService.MouseIconEnabled = false
UserInputService.MouseBehavior = Enum.MouseBehavior.LockCenter
self.X = (self.X - Delta.X) % 360
self.Y = (self.Y + Delta.Y) % 360
local X = math.rad(self.X)
local Y = math.rad(self.Y)
local Orbit = Vector3.new(
math.sin(X) * math.cos(Y),
-math.sin(Y),
math.cos(X) * math.cos(Y)
)
local Target = self.Primary.Position + (Orbit * RAY_EXTEND)
self.Hit = CFrame.new(Target, self.Primary.Position)
end
--[[ Initialization ]]--
function CustomMouse:Start(): ()
self:_Update(Vector3.zero)
UserInputService.InputChanged:Connect(function(InputObject, IsTyping)
if IsTyping then return end
if InputObject.UserInputType == Enum.UserInputType.MouseMovement then
local Delta = InputObject.Delta * SENSITIVITY
self:_Update(Delta)
end
end)
end
--[[ Public Methods ]]--
function CustomMouse:GetPosition(): Vector3
return self.Hit.Position
end
However, there’s a problem, weirdly, the mouse position gets in the center of the self.Primary and not circling it.
I made the camera look to the mouse position with an extra distance and it works as it should, but it’s just weird because the position is located on the center of the primary part and that’s only it.