HUD Moving from player movement

How can I make the HUD move relative to where the player moves, like This

Edit: I guess I wasn’t clear, I’m not talking about the minimap, I’m talking about the entire HUD moving when the players camera moves, you can see the HUD following behind appearing like its not moving with the camera fast enough.

3 Likes

I am guessing your talking about the mini map. One way would be to move the map depending on the rotation and position. All you would need to do is make sure the speed on the UI is the same as the character, then just move the position to the new one. Also, minimaps that I have created move the map image not the character icon/arrow.

1 Like

Not the minimap, the actual HUD, where it moves when the player jumps up onto the ledge, and makes it seem like the UI isn’t actually connected to the camera, but appears like it is following the camera.

Ok then I have no idea. Sorry.

I guess you could just setup a state system where whenever the player is in a “wall jumping” state, then you just move the UI down. That’s my only guess.

You should use a ViewportFrame with a copy of the map inside a new camera and use Camera:WorldToScreenPoint() (with that new camera instance) to get the player instance relative to the Viewport.

Just like what @zblox164, you could detect certain humanoid states that occur just as landing, running, etc.
Then, once detected, play the animation/tweens on the gui to behave how you’d like it to.

If you want to go more in-depth, detect states and movement direction of the player/humanoidrootpart. Then corrolate that position/movement to a tween for the gui. Tween back the gui to its normal location as normal of course when nothing is happening :man_shrugging:

EDIT: To corrolate more in-depth again of course, you can detect the movement of the camera via cframe/focus, and of course, use some math to make it relative to the GUI/HUD itself.

1 Like

Honestly, I think they did that custom to happen when you “vault” onto an object (when vault code is executed, the minimap tweens down and back up as seen in the video). You could make it do this all the time, by locally checking the difference of their Y position every RenderStepped, and update the GUI(s) in the HUD accordingly. I would also set a maximum value of displacement, since there are certain things that could cause massive displacement (such as falling from a high distance, or flinging into the sky, or going up fast on a moving elevator).

Looking closely, it appears to move when he just moves his camera from side to side.

1 Like

You mean the map turning? I wouldn’t call that the HUD moving, but that can be done easily by matching the rotation of the map to the rotation of the character.

1 Like