Hey there, and thanks for reading in advance.
Since particles don’t emit from viewport parts, I’m attempting to cheat a bit by using a screen position to CFrame a part in my camera that has particles inside it.
Problem is, I can’t quite figure out the correct math such that the part is ‘flush’ with the screen, I.E. facing dead-on as if it were a UI element.
Here’s the code I’m currently running to create this effect. If anyone knows how I can achieve the desired flat-ness I’m after, I’d appreciate your help or input.
RUN:BindToRenderStep("CritMeterBoxAlign", Enum.RenderPriority.Camera.Value, function()
local Abs_Pos = UI.StatPanel.CritCircle.AbsolutePosition
local Abs_Size = UI.StatPanel.CritCircle.AbsoluteSize
local Screen_Pos = Abs_Pos + Abs_Size / 2
local Ray = Camera:ScreenPointToRay(Screen_Pos.X, Screen_Pos.Y)
local WorldPosition = Ray.Origin + Ray.Direction * 2
local CameraPosition = Camera.CFrame.Position
local TowardCamera = (CameraPosition - WorldPosition).Unit
local Right = TowardCamera:Cross(Camera.CFrame.UpVector).Unit
local Up = Right:Cross(TowardCamera).Unit
local rotOffsetX, rotOffsetY, rotOffsetZ = 0, 0, .35
if CritGlowBox and CritGlowBox.Parent then
CritGlowBox.CFrame = CFrame.fromMatrix(WorldPosition, Right, Up, -TowardCamera)
* CFrame.Angles(rotOffsetX, rotOffsetY, rotOffsetZ)
end
end)
