Hello Guest

Author Topic: Mouse Position with tk2dCamera  (Read 3967 times)

Arnold

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 32
  • Create something you love!
    • View Profile
Mouse Position with tk2dCamera
« 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!

« Last Edit: October 13, 2013, 04:53:24 pm by Arnold »

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Mouse Position with tk2dCamera
« Reply #1 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.