Convert Mouse Position to World Position - Cave Engine

Does anyone know how to convert mouse position to world position in Cave Engine?
I need to convert to make an entity follow the mouse and, when I click, instantiate an entity exactly at the position my mouse is at.
Replies (3)

Alguém sabe como converter a posição do mouse para o world Position na Cave Engine?
Preciso converter para fazer com que uma entity siga o mouse e quando eu clicar, instanciar uma entidade exatamente na posição em que meu mouse está.

There is no such think as convert the mouse position into the world position since the mouse is 2D. Think about ir this way: lets say you have a camera in real life, then you get a pen an put a dot on the camera lens. You can see the dot from the camera... but what is the world position of this dot in the v real world? Well, at the camera lens, probably. Just like any other dot you put over there.
The same thing is true for the mouse position.
What you want to do here instead is get this position, in the camera lens, and use it to cast a ray (raycast) from the camera and see what it collides with. So look for the raycast method in the camera and you will know what to do.
If you need further assistance, let me know!
In cave 1.3 there will be a function that does something very similar for you, since this is a common question I receive.

I ended up not having time and couldn't focus on it any further, but some of the tests I did, I couldn't get it to work. If you have any examples and could share them, I still haven't figured out how to get the mouse position on the screen and convert it to get the position with a raycast.