Hi!! I’m trying to send a Raycast from the position on which the finger touch the screen but until now i have failed completely
Any tips/help/NonUnityofficial documentation that you can spare with me?
It is a 2D game and the future idea is to grab a position and send a gameobject to it … like a touch-to-move kinda game. (It is not a sidescroller)
What i have now:
if (Input.touchCount > 0 && Input.GetTouch (0).phase == TouchPhase.Began)
{
Ray ray = Camera.main.ScreenPointToRay( Input.GetTouch(0).position );
RaycastHit hit;
if ( Physics.Raycast(ray, out hit))
{
Debug.Log("something is hitted");
}
}
Pretty basic code but it doesn’t work … is it because it’s a 3D code on a 2D enviroment(?)