Thanks Vegas. I was able to get it to display each box when moused over (Also changed the names from Entity... to Box...)
alex = getObject("Alex")
model = getObject("Model")
click = getObject("Click")
text = getObject("Text")
deactivate(model)
Unprojected = getObject("Unprojected")
Camera0 = getObject("Camera0")
function Spin(x)
if isKeyPressed("D") then
rotate(x,{0,0,1},3)
end
if isKeyPressed("A") then
rotate(x,{0,0,1},-3)
end
end
function Switch(x,y)
if isKeyPressed("RIGHT") then
playSound(click)
deactivate(x)
activate(y)
end
if isKeyPressed("LEFT") then
playSound(click)
deactivate(y)
activate(x)
end
end
function onSceneUpdate()
Spin(model)
Spin(alex)
Switch(model,alex)
--[[----------------------------------------------------------------------UNPROJECTED POINT]]
mx = getAxis("MOUSE_X")
my = getAxis("MOUSE_Y")
V1 = getUnProjectedPoint(Camera0, vec3(mx, my, 0))
V2 = getUnProjectedPoint(Camera0, vec3(mx, my, 1))
point, Unprojected = rayHit(V1, V2) -- note that rayHit only detects objects with physics enabled
if point then
Xname = getName(Unprojected)
Xobj = getObject(Xname)
setText(text,Xname)
print(Xname)
if Xname == "BoxR" and onKeyDown("MOUSE_BUTTON1") then deactivate(Xobj) end
if Xname == "BoxL" and onKeyDown("MOUSE_BUTTON1") then deactivate(Xobj) end
if Xname == "BoxT" and onKeyDown("MOUSE_BUTTON1") then deactivate(Xobj) end
end
end