Hello everyone,
I have a fairly simple problem:
I have a 2 dimensional map, with varying models loaded on top. However, the models aren’t everywhere. If a tile is missing, nothing is drawn.
When the user clicks, I want to know the hypothetical position of the object, and draw a model there. Thus, I need to know from a screen click (or tap), what position on y=0 the user meant.
I thought of two different solutions, but could not quite solve the problem:
- Use a
Ray
and an invisibleSpatial
. Maybe I could cull the spatial backwards, but that seems excessive and not optimal. - Use some vector magic using
cam.getDirection()
andcam.getLocation
. I tried this, but it failed (not sure why). I used:origin + (origin.y / -direction.y) * direction
.
What is the best/most efficient way of doing this?
PS: I don’t think you need any code, but feel free to ask if you need it.