Moving screen gui with player movement

Sorry if this is in the wrong category but,
I’m trying to make a gui on your screen that moves with the characters movements like in the game Untitled FPS Game DEMO. I’m not quite sure how they did it, so if anyone knows, please tell me!

Thanks.

8 Likes

FYI, this belongs in #help-and-feedback:scripting-support

9 Likes

alright, i didnt know, my bad lol

5 Likes

Also, you think you could provide a video or smth cuz I am unable to open the game and check.

7 Likes

yeah sure give me a sec to get a vid rq

4 Likes

6 Likes

so my conclusion is that it defienitely can’t be viewport frames because viewport frames don’t allow UI to be rendered, so my next best guess is that they have 3 parts that are basically stuck at that position on the screen relative to the camera and then whenever the player’s camera moves it uses the last position of the camera to kind of give it that sway kind of motion, and of course they have what im guessing to be a surface gui to display

similiar to something like this

3 Likes

alr thx! is it possible to go in depth about where to put the part and how to do it?

1 Like

I’m actually trying to create this effect right now as fast as I can, i’ll get back to you very soon

2 Likes

oh! ok thank you very much for your help!

2 Likes

This is the best I could do just from looking at the video but basically I just got the sway of the camera on the X and Y and then in a runservice loop I lerp the parts position to a specific cframe relative to the camera

local function Lerp(a,b,t)
return a + (b - a) * t
end
  
local Camera = workspace.CurrentCamera
local sway = 0
local sway2 = 0
local lerpSpeed = 5
local swayMultiplier = 10
      	
game:GetService("RunService"):BindToRenderStep("CameraSway", Enum.RenderPriority.Camera.Value + 25, function(deltaTime)
   
  local MouseDelta = UserInputService:GetMouseDelta()
   
  sway = Lerp(sway, math.clamp(MouseDelta.X, -1,1) * swayMultiplier, (lerpSpeed * deltaTime))
  sway2 = Lerp(sway2, math.clamp(MouseDelta.Y, -1,1) * swayMultiplier, (lerpSpeed * deltaTime))
  Camera.CFrame = Camera.CFrame * CFrame.Angles(0, 0, math.rad(-sway))
  	
  test.CFrame = test.CFrame:Lerp(camera.CFrame * CFrame.Angles(math.rad(-sway),math.rad(-sway2),math.rad(-sway)) + camera.CFrame.LookVector * 10 + camera.CFrame.RightVector * -6, deltaTime * 25)
  
end)
3 Likes

thats looks good! thanks sooo much! i’ve been trying to figure this out for so long now. Finally, i’ve found out how to do it!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.