Position rendercam camera (SOLVED)


#1

I have problem regarding positioning rendercam (https://github.com/rgrams/rendercam) camera. When I run 2D game with orthographic camera setup and click in the center of the screen I notice that the action.y (in on_input function) value doesn’t point at the center of the screen. The action.x is somewhat correct but the action.y is way offset from the center of the screen. The game object which contains the rendercam script (camera.go) is positioned at (0,0,0) and is not contained inside another game object. How can I position the rendercam at the center of the world so that I get correct touch position on the screen? Any suggestion would be appreciated. Thx


#2

What are you trying to do with action.x and action.y? Do you want to interact with objects in your game world or with GUI nodes?

RenderCam has a bunch of different transform functions to convert coordinates into the correct space. If you want to get the world position of a touch, with an orthographic camera, use:

rendercam.screen_to_world_2d(action.screen_x, action.screen_y)
-- Make sure to use action.screen_x and action.screen_y, NOT action.x and action.y

If you want to use gui.pick_node to check if GUI nodes are under the touch position, you can just use action.x and action.y.


#3

Exactly what I needed, thx for quick response.