i tried to use the raycast function but got some errors:(in javascript this is easy)
Physic.Raycast (origin : Vector3, direction : Vector3, out hitInfo : RaycastHit, distance : float = Mathf.Infinity, layerMask : int = kDefaultRaycastLayers);
how to set the parameter hitinfo?
i tried:
RaycastHit hitinfo=new RaycastHit();
Physic.Raycas(transform.position,direction,hitinfo,100,…);
the editor raise an error said that can convert type &hitinfo to hitinfo!!
Once i use “&hitinfo”,also got another error “can’t use unsafe code…”!
what is the right way to set this parameter??
thanks!!
try this:
Physic.Raycas(transform.position,direction, out hitinfo,100,…);
I have the same problem (in iPhone Advanced) and adding ‘out’ didn’t fix it:
The best overloaded method match for `UnityEngine.Collider.Raycast(UnityEngine.Ray, out UnityEngine.RaycastHit, float)’ has some invalid arguments
Physics.Raycast complains the same way. In fact, before I moved the Raycast hit into the global area, it complained that it was being used without initialization, even though it’s an out param. Any ideas at all?
Arrrgh! I hate finding a problem two minutes after posting – the RaycastHit wasn’t the issue anymore (after adding ‘out’). It was the distance parameter, a double where Raycast wanted a float: solved by adding an f to the constant. 
Both of your complaints happen to me all the time. 