LwgoDev
(LwgoDev)
January 27, 2023, 11:14am
#1
You can write your topic however you want, but you need to answer these questions:
What do you want to achieve? Keep it simple and clear!
A GUI kinda follows and rotate the camera like in this video that I saw Video
The Health GUI kinda follows the camera if the camera rotate
What is the issue? Include screenshots / videos if possible!
Idk how to sync the rotation & positon with camera
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I looked in dev hub but nothing.
1 Like
BirdieI90
(Ping)
January 27, 2023, 12:39pm
#2
try UserInputService:GetMouseDelta()
and Lerp
local UserInputService = game:GetService("UserInputService")
local Gui = script.Parent -- the gui thingy
local GuiPos = Gui.Position
UserInputService.InputChanged:Connect(function(Input)
if Input.UserInputType == Enum.UserInputType.MouseMovement then
local Delta = UserInputService:GetMouseDelta()
Gui.Position = Gui.Position:Lerp(GuiPos + UDim2.fromOffset(Delta.X, Delta.Y), 0.1)
end
end)
or another solution
look at the mess I did
local RunService = game:GetService("RunService")
local UserInputService = game:GetService("UserInputService")
local TweenService = game:GetService("TweenService")
local Frame = script.Parent -- change it
local FramePosition = Frame.Position
local FrameOffset = FramePosition
local X, Y = {["Goal"] = 0, ["Tween"] = nil, ["Value"] = Instance.new("NumberValue")}, {["Goal"] = 0, ["Tween"] = nil, ["Value"] = Instance.new("NumberValue")}
RunService.RenderStepped:Connect(function(Deltatime)
local MouseDelta = UserInputService:GetMouseDelta() * 0.5
if X.Goal ~= MouseDelta.X then if X.Tween then X.Tween:Pause() end X.Goal = MouseDelta.X X.Tween = TweenService:Create(X.Value, TweenInfo.new(0.2), {["Value"] = MouseDelta.X}) X.Tween:Play() end
if Y.Goal ~= MouseDelta.Y then if Y.Tween then Y.Tween:Pause() end Y.Goal = MouseDelta.Y Y.Tween = TweenService:Create(Y.Value, TweenInfo.new(0.2), {["Value"] = MouseDelta.Y}) Y.Tween:Play() end
FrameOffset = UDim2.fromOffset(
X.Value.Value,
Y.Value.Value
)
--print(FrameOffset)
--print(CameraRotation)
Frame.Position = FramePosition + FrameOffset
end)
2 Likes
system
(system)
Closed
February 10, 2023, 12:40pm
#3
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.