On minute 15:01 , You can see the interaction appears on a specific distance-range Between the player and the button, and also appears even when not looking at the button, basically behind , any ideas on how to do this?
What you can do is to convert the object’s XYZ position to XY screen positions.
local camera = game.Workspace.CurrentCamera
local proximity = nil -- Set this to a part that should have a interactive action
local vector = camera:WorldToViewportPoint(proximity.Position)
vector = Vector2.new(vector.X, vector.Y) -- vector returns a Vector3 object, where Z is the depth.
Then, we clamp the vector
variable, making the interactive action only be able to move in a smaller square.
local viewportSize = camera.ViewportSize
local padding = Vector2.new(20, 20) -- Change them to your liking
local minArea, maxArea = padding, Vector2.new(viewportSize.X - padding.X, viewportSize.Y - padding.Y)
vector = Vector2.new(math.clamp(vector.X, minArea.X, maxArea.X), math.clamp(vector.Y, minArea.Y, maxArea.Y))
Then, we can position the interactive action to the vector
variable.
action.Position = vector
The action button can also be disabled by checking if the vector
variable goes way far beyond the viewport limit.
Note that your ScreenGui must have UI Insets ignored.
This could work, Thank god i am using a imagelabel for this, But should i use a Billboard gui for a more accurate result ?, or should i keep it like this?, also how i could Reset it to his original position, As if nothing happened?, when the player looks back at the “object”
(i think i should had to specify this on the post aww man)
You don’t have to forcefully script a BillboardUIs Position, which would be recommended, probably. I believe it appeared on the side of the screen for 0.1 seconds after turning because it was glitched, not because it was a feature. Though you’d have to do the Method above if you want that effect…