I have a factory spawning game objects upon clicking at the location of action.x, action.y.
However, if I move the camera, when I click the objects are appearing in a different location from where I clicked!
They seem to spawn in the worldspace relative to where my mouse is on my monitor. But because I have moved the camera the monitor.x monitor.y locations do not match the worldspace.x worldspace.y, locations if you will.
Can anyone suggest a solution?
N.B. action.screen_x and action.screen_y do not work either.
action.x and action.y will give you the coords for your screen, not the world coords.
Just take the action coords and add the camera coords and it will be correct?
In the end it wasn’t the camera position that had to be added, it was the vector difference between the current camera position and the starting position of the camera