How can you get an object to point to the mouse pointer?

The relevant snippet of code:

local look_at = vmath.vector3(123, 456, 0) -- the position to look at
local my_position = go.get_position()
local angle = math.atan2(look_at.x - my_position.x, look_at.y - my_position.y)
go.set_rotation(vmath.quat_rotation_z(angle))
4 Likes