Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How would I use this camera function?

Asked by 8 years ago

I've been trying to figure out how to use the Camera function, ScreenPointToRay() to see if I could use it to make Radars', but the problem is that I don't know where to start!

Link here: http://wiki.roblox.com/index.php?title=API:Class/Camera/ScreenPointToRay

1 answer

Log in to vote
0
Answered by 8 years ago

ScreenPointToRay lets you, for example, determine where the player is pointing in the workspace given their mouse coordinates; that is, it'll give you a ray which you can use to raycast to see what the player's mouse is resting on (if anything).

Raycasting is probably too inefficient for your radar. It's probably better is to go through all objects you're thinking of displaying on the radar and determining their position on the radar based on the camera's current .CoordinateFrame (possibly based on the .CoordinateFrame.lookVector)

If you have the position of a model or part, you can use:

relativePos = workspace.CurrentCamera.CoordinateFrame:pointToObjectSpace(pos)

Now, if 'pos' is straight ahead 5 studs relative to the camera, relativePos will be equal to Vector3.new(0, 0, -5).

0
Thanks bro! mistaLangston 10 — 8y
Ad

Answer this question