2D Toolkit Forum

2D Toolkit => Support => Topic started by: Arnold on October 13, 2013, 02:45:32 pm

Title: Mouse Position with tk2dCamera
Post by: Arnold on October 13, 2013, 02:45:32 pm
Hey,

i'm trying to get the Input.mousePosition.x on a tk2dCamera with an upper Left Anchor. The script is attached
to a child of the Anchor. I'm using a iPhone 5 640x1136px Resolution, but the values i get from the mouse are not correct.
I tried some stuff with ScreenToWorldPosition() as suggested, than the values are correct but 0,0 is no longer on the top left.

What i want are the "real" positions of my click/touch based on the screen size (top left 0,0 or bottom right 640,-1136).

How do i do this?

Thanks!

*** Solved my own Question: Problem was that i had the tk2DCamera Origin to center instead of Bottom Left. Now my ScreenToWorldPosition Value is correct!

Title: Re: Mouse Position with tk2dCamera
Post by: unikronsoftware on October 13, 2013, 05:52:46 pm
ScreenToWorldPosition should work regardless of origin. You just need to compare relatively with the objects in world space - eg. an object at 0, 0, 0 would be at the center if the origin is the center.