from java to c#

hi!
i need this script in c# but cant figure out how to convert it.

var playerPlane = new Plane (Vector3.up, transform.position);
		
		var ray = Camera.main.ScreenPointToRay(Input.mousePosition);
		
		var hitdist = 0.0;
		
		if (playerPlane.Raycast (ray, hitdist)) 
		{
			var targetPoint = ray.GetPoint (hitdist);
			
			var targetRotation = Quaternion.LookRotation (targetPoint - transform.position);
			
			transform.rotation = targetRotation;
		}
		Plane playerPlane = new Plane(Vector3.up, transform.position);
		Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
		float hitdist = 0.0f;
		if (playerPlane.Raycast(ray, hitdist))
		{
			Vector3 targetPoint = ray.GetPoint (hitdist);
			Quaternion targetRotation = Quaternion.LookRotation (targetPoint - transform.position);
			transform.rotation = targetRotation;
		}

To make this post a bit more usefull for others that have the same issue, I’ll explain how to convert :

var targetPoint = ray.GetPoint (hitdist);

To convert this line to C#, all you need to find out is the type it will return.
You can find that in several ways.
In many cases your script editor will show it or you can look up the method in the scripting reference :
Ray.GetPoint.html
So in this case it’s a Vector3 type.
And then you need to find the right C# syntax which is almost allways the same :

Vector3 targetPoint = ray.GetPoint (hitdist);
Type variable = method()

This realy is childsplay if you know the C# syntax.
Hope this helps.

http://files.m2h.nl//js_to_c.php

This will do most of the work but you have to check the result for yourself ofcourse :slight_smile: