- Home /
translate function in Js script to c#
Hi guys!
I'm currently porting a .js script into a c# script, and I'm struggle with a function:
This is JS
public static function PlaneRayIntersection (plane : Plane, ray : Ray) : Vector3 {
var dist : float;
plane.Raycast (ray, dist);
return ray.GetPoint (dist);
}
What is " : Vector3 " doing at the end of the function, outside the brackets?
And C#
public static function PlaneRayIntersection (Plane plane, Ray, ray) //Vector3???
{
float dist;
plane.Raycast (ray, dist);
return ray.GetPoint(dist);
}
Does anyone knows how to translate that?
Thanks in advance
Comment
Best Answer
Answer by sleepandpancakes · May 19, 2017 at 03:13 PM
The Vector3 is denoting the return type of the function. So in C# we use that instead of the function keyword:
public static Vector3 PlaneRayIntersection (Plane plane, Ray ray)
{
float dist;
plane.Raycast (ray, out dist);
return ray.GetPoint(dist);
}
Your answer
Follow this Question
Related Questions
Help with function code, passing Vector3 info 1 Answer
Translate this statement from .js to C# 2 Answers
How to get point a set distance along a direction 1 Answer
Create a Custom Vector3 Object 2 Answers
Translate Vector3 by Vector3 1 Answer