Topic: Set object position to mouse x and y position

so heres my simple code:

Camera =getObject("Camera0")
player = getObject("Entity0") 



function onSceneUpdate()
colorr=math.random(0, 2)
colorg=math.random(0, 2)
colorb=math.random(0, 2)




getX = getAxis("MOUSE_X")
getY = getAxis("MOUSE_Y")

var1 = updateMatrix(getX)
print (var1)



Camera = getCurrentCamera()
setCameraClearColor(Camera, {colorr, colorg, colorb})




end

i'm trying to set the position of player to mouse position but when i use "getAxis("MOUSE_X") it throws out a strange float, what can i do with this data?

Last edited by blend (2017-01-02 01:04:02)

Re: Set object position to mouse x and y position

I actually figured it out:

Camera =getObject("Camera0")
player = getObject("Entity0") 



function onSceneUpdate()
colorr=math.random(0, 2)
colorg=math.random(0, 2)
colorb=math.random(0, 2)




mx = getAxis("MOUSE_X")
my = getAxis("MOUSE_Y") 
mz = 0.0   

cursor3d = getUnProjectedPoint(Camera, vec3(mx, my, mz))
print(cursor3d[1], cursor3d[2], cursor3d[3])
setPosition(player, {cursor3d[1], cursor3d[2], mz})






Camera = getCurrentCamera()
enableCameraOrtho(Camera, true)
setCameraClearColor(Camera, {colorr, colorg, colorb})




end

this will set player cords to mouse.