js to c#

How to convert this:
var ray = Camera.main.ScreenPointToRay(Vector3(Screen.width/2, Screen.height/2, 0));
if(Physics.Raycast(ray, hit))
{
in to c#?

add new in front of Vector3

js implicitly does the out thing for you, so add out in front of hit param.

var ray = Camera.main.ScreenPointToRay(new Vector3(Screen.width/2, Screen.height/2, 0));
if(Physics.Raycast(ray, out hit))

ive used this before. takes some further tweaking afterwards, but i find that when converting scripts it does quite a bit of the legwork for you, and saves me time personally. Convert unity javascript (unityscript) to C#

Thanks!! and what about this one?
var hitRotation = Quaternion.FromToRotation(Vector3.up, hit.normal);

Quaternion hitRotation = Quaternion.FromToRotation(Vector3.up, hit.normal);

what happens when you run the script? do you get errors?

I solved it :slight_smile: the problem is that i Sended message to a js script not c#