I am new with Unity and I need rays to work in 2d, so I am trying to use Ray2D, but I got this weird error:
Cannot implicitly convert type `UnityEngine.Vector2' to `UnityEngine.Ray2D'
Here is the code line which causes error:
Ray2D ray = new Vector2 (Camera.main.ScreenToWorldPoint(Input.mousePosition).x, Camera.main.ScreenToWorldPoint(Input.mousePosition).y);
And here is whole function that causes error:
void touching2D (Vector3 touchPosition, int touchNumber)
{
Ray2D ray = new Vector2 (Camera.main.ScreenToWorldPoint(Input.mousePosition).x, Camera.main.ScreenToWorldPoint(Input.mousePosition).y);
RaycastHit hit = new RaycastHit();
if(Physics2D.Raycast(ray, out hit,130))
{
hit.collider.SendMessage("pressed");
touchedSomething = "Yes!";
}
}