Gui help: Crosshair appears above the vector3 position given

Hello!!!
SO I am trying to make like an active crosshair where the aim of the weapon updates the crosshair of where the bullet will actually hit to make a crosshair accurate to the environment.

local screenPosition: Vector3, inView: boolean = workspace.CurrentCamera:WorldToScreenPoint(crosshair_primary_part.Position)
aim_gui.Position = UDim2.fromOffset(screenPosition.X, screenPosition.Y)

This is the code that does that, its in a runservice function (Heartbeat) and does update accurately, but one problem.

The cross hair appears above the actually position:

The red is the GUI (anchor point is set .5, .5 as well)
The white is a raycast beam which then gets the position of the contact point. This is used as the Vector3 coords [ref: crosshair_primary_part.Position]

This might be an easy fix, but I might not see it. Any help is appreciated!

1 Like

I believe this may happen due to IgnoreGuiInset enabled on the ScreenGui. If you have it enabled on the crosshair ScreenGui, try disabling it and see what happens.

4 Likes

or alternatively, use Camera:WorldToViewportPoint()

2 Likes

image
Works fine now! Thanks for the help! That did the trick!!!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.