RayHit
(Difference between revisions)
Dahnielson (Talk | contribs) |
Dahnielson (Talk | contribs) |
||
| Line 34: | Line 34: | ||
[[Category:Lua scripting]] | [[Category:Lua scripting]] | ||
| + | [[Category:Lua function]] | ||
| + | [[Category:Physics]] | ||
Revision as of 18:32, 4 February 2014
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
point, object = rayHit(start, end)
or :
point = rayHit(start, end, object)
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