2D Toolkit Forum
2D Toolkit => Support => Topic started by: Euthyphro on September 24, 2013, 10:16:02 am
-
I'm trying to use Input.mousePosition to get mouse click location, however, I can't seem to convert it to the actual position in-game to move an object.
What I'm trying to do is obtain the actual position in game when a mouse is clicked based on a tk2dtilemap and using tk2dcamera. Transform coordinates are based off of the tilemap. I don't want the pixel coordinates based on lower left side of the screen and top right side of the screen, I'm trying to obtain the actual transform position so I can move an object to the point clicked using i.e. Vector3.Lerp(startVector, mouseClickVector, TIme.deltaTime);
I'm not sure of the math or how it works to convert the Input.mousePosition to the actual transform position? Could someone share how they've done this?
Thanks.
-
Convert Input.mousePositiion to a worldPosition using tk2dCamera.Instance.camera.ScreenToWorldPosition(...) - you can then use that world position to move your object, etc.