RayHit

From MaratisWiki
Revision as of 18:17, 8 February 2014 by Dahnielson (Talk | contribs)
Jump to: navigation, search

rayHit(start, end)

Launch a ray and returns the result of the test, the intersection point or nil and optionally the object. Note that only detects objects with physics collision enabled.

point, object = rayHit(start, end)

Or.

point = rayHit(start, end, object)

Example 1: Test the intersection with the full scene.

   function onSceneUpdate()
       start = {0, 0, 0}
       end = {100, 0, 0}
       point, object = rayHit(start, end)
       if point then
           print(point) -- print point
           print(getName(object)) -- print object name
       end
   end

Example 2: Test the intersection with an object.

   object = getObject("object")
   
   function onSceneUpdate()
       start = {0, 0, 0}
       end = {100, 0, 0}
       point = rayHit(start, end, object)
       if point then
           print(point)
       end
   end
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox