Convert C# code to javascript


I’ve a problem with a C#script that i’m trying to convert to javascript.
But i’ve no idea of C# sintax. Can somone convert this for me?

Thanks in advance

Transfo camera r = (Transform)Instantiate(ragdollsToCreate<em>, objectsToKill_.transform.position, objectsToKill*.transform.rotation);*_</em>

* if (!r)*
* {*
_ Debug.LogError("Example.Update() " + name + " could not Instantiate " + ragdollsToCreate*.name);

* {
// get AdvancedRagdoll script*

* AdvancedRagdoll ar = (AdvancedRagdoll)r.GetComponent(“AdvancedRagdoll”);*_

* if (!ar)*
* {*
* Debug.LogError("Example.Update() " + name + " could not get AdvancedRagdoll from " +;*
* }*
* else*
* {*
* // store ragdoll reference*
* ragdolls.Add(ar);*

* // synch ragdoll to current object animation pose*
_ ar.SynchRagdollIn(objectsToKill*.transform);

* // destroy object*
_ Destroy(objectsToKill*);*_

You most likely aren’t going to get people here who are going to spend their time converting your script.

Become a better Unity developer and learn to code in both languages. Trust me, down the line you’ll need to be able to do both if you want to become successful with Unity.

Take a look at this thread for a good read on the syntax differences.

First, the code you posted is full of errors if it is C#.

Transfo camera r = (Transform)Instantiate();
//This isn't a legal line.  It looks like it is supposed to be this:
Transform r = (Transform)Instantiate();

Another error:

//This is legal in js, but in C#, you must do this:
//if(r == null)

But besides for that there isn’t really anything that should cause problems in translating that aren’t obvious changes. Identify variables and declare them in js syntax.

The only thing to remember is that casting in js can only be done with as syntax.

And see this answer for a more in-depth explanation.

Thanks Meltdown en peter!

While you’r answering my question, i’ve tried to convert only the changes i need to c#.

So thank’s again, and sorry to ask you that things but i’m learning animation, 3d design, texturing and javascript. If i have to learn C# too, my head will explode for sure.