Hello. So I'd want to create an object on the cursor position. I have calculated everything, it works fine but there are some objects that do not fit to the calculation. I think the problem can be that the bounding box of this objects are also buggy and I don't know what should I change in my calculation.
Calculation:
local sx, sy = guiGetScreenSize()
local relX, relY = getCursorPosition()
cursorX, cursorY = relX * sx, relY * sy
local camX, camY, camZ = getCameraMatrix()
local cursorWorldPosX, cursorWorldPosY, cursorWorldPosZ = getWorldFromScreenPosition(cursorX, cursorY, 1000)
local hit, hitX, hitY, hitZ, hitElement, normalX, normalY, normalZ = processLineOfSight(camX, camY, camZ, cursorWorldPosX, cursorWorldPosY, cursorWorldPosZ, true, true, true, true, true, true, false, true)
Picture about it: (The red lines show the bounding box of the object)