I'm trying to translate my raycasting experience in Unity and Blender GE to Leadwerks, but I'm having a hard time connecting the dots. My test scene includes one cube on the ground, and another cube next to the first (on X axis) and raised above the ground and above the height of the ground cube so that when the game starts, the raised cube falls next to the ground cube. I have a lua script attached to the ground cube and I'm trying to cast a ray from the ground cubes position to a position farther down the x axis so that the raised cube will intersect when it falls.
This is my code in the UpdateWorld function. I get an blank error window. I'm very inexperienced with Leadwerks, so I may be going about it all wrong, but this is what I've gathered from the docs.
Thanks for any help you can provide.
function Script:UpdateWorld()
self.position = self.entity:GetPosition()
self.right = Vec3(self.position.x + self.right.x, self.position.y, self.position.z);
local pickInfo = PickInfo()
local clear = true
local world = World:GetCurrent()
local context = Context:GetCurrent()
local pos = self.camera:Project(Vec3(self.position))
local pRight = self.camera:Project(Vec3(self.right))
context:DrawLine(pos.x, pos.y, pRight.x, pRight.y)
if (world:Pick(self.position, self.right, pickinfo, 0.0, true)) then
clear= false
end
end