Game Development Community

Mouse position to world position

by William Hilke · in Torque Game Builder · 09/04/2009 (10:42 pm) · 1 replies

I've been searching the forums but I just can't seem to find an answer to what I'm looking to do.

I have my camera attached to my player sprite, to keep the player centered as often as possible.
The player moves around the map by clicking to a new location, which causes the camera to follow the player.

I'm having trouble converting the mouse position from OnMouseDown() into world coords that can be used in object.setPosition().

I've tried using sceneWindow2D.getWorldPoint(), which isn't converting mouse coords to world coords.


Anyone know how to convert local mouse coords to world coords when the camera is a subset of the whole world, and can move?

#1
09/05/2009 (3:28 am)
I figured out my problem. I knew I was going crazy in remembering that mouse events return world positions. I had a gui control overlaying my scene graph, with its own camera position. That was screwing up my mouse events.