Question by
freedom667 · Dec 27, 2015 at 07:25 PM ·
c#unity 5javascriptconvertjava to c#
JavaScript to C#
I couldn't convert this script. can you convert js to c# for me??
#pragma strict
var cameraTarget : GameObject; // Inspector> Assign the Camera Target NON è il target della camera ma la posizione che vuole raggiungere la camera
var smoothTime : float = 0.1; // Delay in seconds to follow Player
var cameraFollowX : boolean = true; // Inspector> if is checked -> The Camera will follow X position of cameraTarget
var cameraFollowY : boolean = true; // Inspector> if is checked -> The Camera will follow Y position of cameraTarget
var cameraFollowHeight : boolean = false; // if true the Camera Y Position = cameraHeight
var cameraHeight : float = 2.5; // cameraHeight
var velocity : Vector2;
var offset : float;
private var thisTransform : Transform;
function Start ()
{
thisTransform = transform;
}
function Update ()
{
if (cameraFollowX) // if cameraFollowX = true = Inspector is checked
{
thisTransform.position.x = Mathf.SmoothDamp (thisTransform.position.x, cameraTarget.transform.position.x + offset, velocity.x, smoothTime);
}
if (cameraFollowY) // if cameraFollowY = true = Inspector is checked
{
thisTransform.position.y = Mathf.SmoothDamp (thisTransform.position.y, cameraTarget.transform.position.y, velocity.y, smoothTime);
}
if (!cameraFollowY && cameraFollowHeight) // if cameraFollowY = false = Inspector is unchecked AND cameraFollowHeight = true = Inspector is checked
{
GetComponent.<Camera>().transform.position.y = cameraHeight; // The Camera Y position = cameraHeight
}
}
Comment
there are free online converters and the syntax of unityscript and c# are very close, it shouldn't produce many (if any) errors for you.
i tried convert and converter but i couldn't positive result. i did everything but it wasn't. it mus be another way.
which converter did you use?
you're better off posting the code that you tried and somebody will most likely help you to find the errors. you don't learn anything if somebody just gives you the code...
Answer by freedom667 · Dec 27, 2015 at 09:59 PM
i converted until the if(cameraFolloy), but after i can't convert.