Skip to content

raylib.GetScreenToWorldRayEx

JoeStrout edited this page Apr 29, 2026 · 2 revisions

Get a ray trace from the screen position (i.e mouse) within a specific section of the screen

Parameters

Parameter Default Value Note
position
camera
width 0
height 0

Return value

Condition Return Value
(always) map

Notes

Example

cam = {position:[0,5,10], target:[0,0,0], up:[0,1,0], fovy:45, projection:raylib.CAMERA_PERSPECTIVE}
// Cast a ray from a specific viewport section (800x600)
ray = raylib.GetScreenToWorldRayEx([400, 300], cam, 800, 600)
print "Ray direction: " + ray.direction[0] + ", " + ray.direction[1] + ", " + ray.direction[2]

Clone this wiki locally