RayHit

(Difference between revisions)
Jump to: navigation, search
(Created page with "Launch a ray and returns the result of the test : the intersection point or nil<br> ''note : only detects objects with physics collision enabled'' Example1, test the interse...")
 
Line 1: Line 1:
Launch a ray and returns the result of the test : the intersection point or nil<br>
+
Launch a ray and returns the result of the test : the intersection point or nil and optionally the object<br>
 
''note : only detects objects with physics collision enabled''
 
''note : only detects objects with physics collision enabled''
  
Line 8: Line 8:
 
         start = {0, 0, 0}
 
         start = {0, 0, 0}
 
         end = {100, 0, 0}
 
         end = {100, 0, 0}
         point = rayHit(start, end)
+
         point, object = rayHit(start, end)
 
         if point then
 
         if point then
             print(point)
+
             print(point) -- print point
 +
            print(getName(object)) -- print object name
 
         end
 
         end
 
     end
 
     end

Revision as of 15:26, 5 February 2013

Launch a ray and returns the result of the test : the intersection point or nil and optionally the object
note : only detects objects with physics collision enabled


Example1, 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

Example2, 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