Physics.Raycast done in C#

Im trying to do somethin like this

 if (Input.touchCount == 1)
        {
            if (Input.GetTouch(0).phase == TouchPhase.Began)
            {
                var ray = Camera.main.ScreenPointToRay(Input.GetTouch(0).position);
                var hit;
                if (collider && collider.Raycast(ray, hit, 100.0))
                {
                    OnMouseDown();
                }
            }
        }

But var hit; complaines that it need to be instanziated. How would i do that? :slight_smile:

You need this - RaycastHit hit = new RaycastHit();

Please format code when posting. I can tell, though, that’s it’s not C#, it’s Unityscript. (But in Unityscript the variable type should still be defined, either explicitly or by supplying a value, so “var hit;” is not really acceptable.)