Converting function variable to CS

Hello guys, usually I don’t ask question like this but I’m stuck and could not find any help. I have an enemy AI javascript code and I try to add it’s attack function to other C# code. I’m stuck in some place I don’t know how to write it in c# so I need help guys.

Js :

function Attack(){

var Hit : RaycastHit;
var direction = bulletAccuracy();  // I couldn't know how to write this in CS

// and raycast stuff that I think I can convert

function bulletAccuracy(){

var spX = (1 - 2 * Random.value) * bulletAccuracy; // and this 

// other stuff that I can covert

I tried

RaycastHit Hit;

for that, and

Vector3 direction = bulletAccuracy();

but then I couldn’t know how to write function bulletAccuracy in js, if I try

void bulletAccuracy(){



IENumarator bulletAccuracy(){


I get errors, how can I write I need only these 2-3 lines guys sorry to ask a question like that but I have no choice.

For a csharp function the first word is the return type

so if you are returning a Vector3

Vector3 bulletAccuracy(){
Vector3 vec3;
return vec3;
then you should be able to use

Vector3 direction = bulletAccuracy();