I’m trying to make the mouse not go past a certain spherical collision, I attached a GO with collisions and etc to make so. The problem is, the GO respects the collisions, but the cursor doesn’t. I ve been trying to make the mouse not go past where it shouldn’t. To do this, I’m using the orthographic camera API to trasnlate from world to screen position, alongside with DefOS to set the cursor position. The problem is, whenever I try to set the cursor position using this code:
function on_message(self, message_id, message)
if message_id == CONTACT_POINT_RESPONSE then
if message.group == collision_groups.min_spin_limit then
-- First, project the accumulated correction onto
-- the penetration vector
local proj = vmath.project(self.correction, message.normal * message.distance)
-- Only care for projections that does not overshoot.
local comp = (message.distance - message.distance * proj) * message.normal
-- Apply compensation
go.set_position(go.get_position() + comp)
local cursor_pos = camera.world_to_screen(CAMERA_ID, go.get_world_position())
-- Accumulate correction done
self.correction = self.correction + comp
print("Cursor:" .. cursor_pos)
print("GO: " .. go.get_position())
defos.set_cursor_pos(cursor_pos.x, cursor_pos.y)
end
end
end
the mouse just snaps to a nonsensical position, like when I collide at the bottom, it snaps the cursor to way above the collision bounds. I don’t know what may be causing this, I get no error when running.