This is the complete 2.8 documentation for Scene.ray_cast

ray_cast (view_layer, origin, direction, distance=1.70141e+38)

Cast a ray onto in object space


view_layer (ViewLayer, (never None)) – Scene Layer

distance (float in [0, inf], (optional)) – Maximum distance

Return: (result, location, normal, index, object, matrix):

result, boolean

location, The hit location of this ray cast, float array of 3 items in [-inf, inf]

normal, The face normal at the ray cast hit location, float array of 3 items in [-inf, inf]

index, The face index, -1 when original data isn’t available, int in [-inf, inf]

object, Ray cast object, Object

matrix, Matrix, float multi-dimensional array of 4 * 4 items in [-inf, inf]

Can someone flesh this out for me?

  • "Cast a ray into object space": which object?
  • Which object's space are origin and direction in? And the returned location?
  • What is the matrix?

Do these all belong to the 'target' object? How would I know what that was before hitting it?

  • 1
    $\begingroup$ Without testing so won't answer, pretty sure all values here are globals. (including the face normal as a global) The matrix being the hit object's matrix_world. $\endgroup$
    – batFINGER
    Jan 29, 2019 at 13:11
  • $\begingroup$ @batFINGER.. not sure ... why would the docs say 'into object space'? I was hoping to avoid testing. when I've done it, I'll let you know.. $\endgroup$
    – Robin Betts
    Jan 29, 2019 at 13:38
  • $\begingroup$ Lazy docs. Could argue it is the "scene objects space". $\endgroup$
    – batFINGER
    Jan 29, 2019 at 14:25
  • $\begingroup$ @batFINGER, Thanks, you're right as usual. It may seem lazy of me not to test it.. but a beginner has to reverse-engineer an awful lot of the API: it gets to be quite time-consuming. $\endgroup$
    – Robin Betts
    Jan 29, 2019 at 16:04

1 Answer 1


@ batFINGER was correct in his commentary.. All vectors are in World Space, the matrix, the hit object's matrix_world.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .