I have tried ViewportSize but that didn’t seem to work, any ideas?
Have you tried using ViewportPointToRay?
The viewportsize divided by 2 is the center of the screen. It should be:
local leftmost = camera.ViewportSize * Vector2.new(0, 0.5)
just tryed your code and it didnt work, still putting the bubble at the center of the screen
It’s probably because whatever Home.CFrame is it’s not at the left of the screen. It also probably is because you need to use ScreenToWorldPoint instead of ViewportPointToRay.
I tried screentoworldpoint as well, but with different code, let me try again thank you
there is no such function ScreenToWorldPoint
Also it cant be the home because its manuiplating the lookvector which is on the Z thats not left and right
Very confusing. What code do you have?
You mentioned the function in this post:
I probably have gotten confused. I will look up the API for this.
the only code i have is the one in the screenshot, i think you got it confused with worldtoscreenpoint
https://create.roblox.com/docs/reference/engine/classes/Camera#WorldToScreenPoint
WorldToScreenPoint is what I was looking for. You would need to apply a similar function to it.
Like what function??? Its still not working when im using the ViewportPointToRay so im not sure what to do
It depends on what you want to achieve. If you have the bubble in the left position already, you can use WorldToScreenPoint
. If you don’t have it, use ViewportPointToRay`.
Ray.Origin
is where the ray starts, so you probably want (ray.Origin + ray.Direction)
instead.
If the Ray.Origin is where it hits you shouldnt need to add the direction, also I quickly tried that now I cant see the bubble
If you want to do this, you can just use the ViewportPointToRay()
with 0 as both parameters to get the top left corner and then use .Origin
for the position.
local cam = workspace.CurrentCamera
local view = cam.ViewportSize
local origin = cam:ViewportPointToRay(
0,
0
)
local offset = cam.CFrame * CFrame.new(0, 0, cam.NearPlaneZ) -- dont let the camera clip it
local p = Instance.new("Part")
p.CFrame = offset * cam.CFrame:ToObjectSpace(CFrame.new(origin.Origin)) -- need to get the offset of the camera and the origin position
p.Size = Vector3.new(0.1, 0.1, 0.1)
p.Parent = workspace
this is pretty basic and can be more complex for more accuracy. If it is fine to clip then just use CFrame.new(origin.Origin)
with no offset or ObjectSpace
The bubble should be 500 studs to your left, which is probably too far to see. You should decrease the direction value so it’s not as far as 500 studs.
I decreased it to 10 and it still didnt work
Is there seriously no simple way to just get my cameras size as if it were a part??
Try the unitray.Direction, which has a value of 1. Make sure the part is in front of the camera and not behind it.