- Home /
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(){
}
and
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.
Answer by TallPaulUK · Jul 27, 2013 at 03:19 PM
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();
Your answer
Follow this Question
Related Questions
Js to C# convert 1 Answer
Deactivate Controlle of one object and Contoll another 2 Answers
Help convertings c# to js line --using Callback=System.Action 1 Answer
C# to JS small error 2 Answers
Space Craft controller. 1 Answer