I’m trying to make a “3d” UI to use in displaying weapons on the screen. I know usually you would be using viewport frames but in my case I want to display particle emitters. The issue I’m currently having is that it is scaling up in size dependant on how far it is form the center of the screen.
local function updateBackgroundPartPosition()
local uiPosition = inspectFrame.InspectFrame.ItemDisplayFrame.AbsolutePosition
local uiSize = inspectFrame.InspectFrame.ItemDisplayFrame.AbsoluteSize
local adjustedDistance = distanceFromScreen * 1.5
local viewportHeightRatio = uiSize.Y / camera.ViewportSize.Y
local centerUIPosition = uiPosition + (uiSize / 2)
local centerRay = camera:ScreenPointToRay(centerUIPosition.X, centerUIPosition.Y)
local centerWorldPos = centerRay.Origin + centerRay.Direction * adjustedDistance
local frameWorldHeight = 2 * adjustedDistance * math.tan(math.rad(camera.FieldOfView / 2)) * viewportHeightRatio
local aspectRatio = uiSize.X / uiSize.Y
local frameWorldWidth = frameWorldHeight * aspectRatio
self.Background.Size = Vector3.new(frameWorldWidth, frameWorldHeight, 0.001)
self.Background.CFrame = CFrame.new(centerWorldPos, centerWorldPos - camera.CFrame.LookVector)
end
This is the attempt I made. I’m trying everything I can to make it work with FOV but I’m having issues trying to do that
Ive made other attempts as well like:
Getting position for corners of the UI and scaling the 3D “UI” Using the distance between them. That made it appear even more distorted tho (for some reason)
Ive also tried using a Billboard GUI but the refresh rate of the Billboard GUI is too slow to catch up with the speed of the camera
when games such as the source engine want to display something on a screen (basically the same idea as your gui), they have a far off room with the model being displayed. a part facing said model is inside this room and the player’s camera is set to be that part. this is probably one of the better ways to display a new item you have just got while being able to display particles. if moving the entire camera to some far off room isn’t your cup of tea, try what hya123456h suggested (“loads of guilt particle emitter modules”).
I see, the issue is i am also attempting to do the same thing for the inventory. And if i do it that way it will be inconvenient for the player to move them to a whole new room every time.
Here is how it looks in the inventory, not as bad but i would still like the freedom of moving it around the screen to any position without worry
I cant, roblox doesnt allow it since viewports dont render particle effects (for some reason). For the inventory ones im thinking i will just use drawn icons for it on a template knife. I think im close to the solution but i just cant seem to get it.
Im not worried about inventory icons right now, im worried about the right side where the 3d Model is. I want to make the background of it scale properly
I think having a 3d thing is much more effective. Then you can see the actual model. And the 2d paritcle emitters wont make it look exactly like the actual thing.