Help by converting JS/US in to C#


i tried to convert some js in c# for my RTS and im chocking atm at this part

//Single Unit Selection
if (Input.GetMouseButtonDown(0))
    selectionEnded = false;
    //Cast Ray to hit Ground
    Ray ray_ground = camera.ScreenPointToRay(Input.mousePosition);
    RaycastHit hit_ground;
    int ground_Layermask = 1 << 8; // not sure what this << means couldnt google it

    // givs the error: best match Raycast(UnityEngine.Ray,out UnityEngine.RaycastHit, float, int)  
    if (Physics.Raycast(ray_ground, hit_ground, Mathf.Infinity, ground_Layermask))

        selection_Start = hit_ground.point;    //Store initial hit
    //Cast Ray to Select Unit
    Ray ray = camera.ScreenPointToRay(Input.mousePosition);
    RaycastHit hit;
    int unit_Layermask = 1 << 10;

    //smae story
    if (Physics.Raycast(ray, hit, Mathf.Infinity, unit_Layermask))
        //Store Unit in Selectables
        hit.collider.GetComponent<Selectable>().selected = true;

        // selectables is a List<GameObject> still its gives a error that its want a GameObject

    //Didn't click on Ground
    //Store the Mouse position
    start_Mouse = Input.mousePosition;

try :

if (Physics.Raycast(ray_ground, out hit_ground, Mathf.Infinity, ground_Layermask))

note the added keyword out

if you click on the Unity Scripting Reference : Unity - Scripting API: Physics.Raycast

at the top-right of the example script window, there is a button JavaScript ||

well it’s a down arrow. click on that, and the example script should change to C#

now you can ask Unity Scripting Reference to convert alot of builtin functions.

try it with layermask