Hi there,
I’m using raycast and I’ve got a weird issue. Right now, I’m using exactly what’s written in the documentation, which is :
[lua]hitLeft = physics.rayCast(point1.x, point1.y, point1.x, -50+point1.y + 300, “closest”)
if ( hitLeft ) then
– There’s at least one hit
print( "Hit count: " … tostring( #hitLeft ) )
print( "The first object hit is: ", hitLeft[1].object, " at position: ", hitLeft[1].position.x, hitLeft[1].position.y, " where the surface normal is: ", hitLeft[1].normal.x, hitLeft[1].normal.y )
local reflected_ray_direction_x, reflected_ray_direction_y = physics.reflectRay( 0, 0, hitLeft[1] )
print( "Reflected direction: ", reflected_ray_direction_x, reflected_ray_direction_y )
else
– No hits
end[/lua]
hitLeft[1].object always returns “nil”, but hitLeft[1].position.x DOES return coordinates. Can’t figure out why…