Raycast in C# - problem

Hi All,
I have been porting some of my code from javescript to c#;
for the purpose of compiling externally into dlls

Mostly this works, but I have been getting an error
when using Raycasts;

public class TerrainAwarness : MonoBehaviour
    {
        
        public float slopeAngle ;
        public float slopeRise ;
        public float slopePreviousRise;
        public float distanceToGound;
        public GameObject   go;
        public RaycastHit   groundBelowHit;
        
        
    
    public RaycastHit       GroundHit()
    {
       Physics.Raycast (go.transform.position, Vector3.down,groundBelowHit) ;

     return  groundBelowHit;
    }
    
    
    
    
    
    }

compiling with mcs i get :

if i give it a float ie the raylength ie

Physics.Raycast (go.transform.position,  Vector3.down,groundBelowHit,10.0F)  ;

after compiling with mcs i get :

I seems i can not return the actual hit like in javascript.

Any help would be appreciated !

You need to add the out keyword to the third parameter. I.e.

Physics.Raycast (go.transform.position, Vector3.down, out groundBelowHit);

The out keyword means that the groundBelowHit variable will be passed by reference instead of by value.

Many thanx :smile: