- Home /
Can I use Javascript (Unityscript) for Box2D for Unity or Farseer Physics?
I've spent a few months learning everything in Unity in Javascript and would prefer to stay in JS wherever possible. Due to the physics I want in my network multiplayer game project I would require some sort of 2D physics system so I can rewind and simulate properly, but I really don't want to learn C# if I can avoid it.
These are the implementations on the asset store I've been looking into:
Box2D for Unity Farseer for Unity
Would it be possible to use these script / functions in Javascript?
Answer by Benproductions1 · Sep 13, 2013 at 12:14 AM
Hello,
Because of the way Unity works (and frankly if it didn't work this way that would be very bad), all scripts compile down to the same thing. It doesn't matter if you write var integer:int;
or public int integer;
, after compiling it they are one and the same.
This allows for cross use of each language. You can always (except in very specific cases) call any function in C# as you can in UnityScript. Sometimes the documentation of packages are only in C# (and rightly so), but translating it is quite easy.
Most projects actually (when using packages) end up having quite a mix of javascript and C#
From a technical point of view, the only real difference between UnityScript and C# are syntax and defaults (as well as missing feature implementations in UnityScript)
Hope this helps,
Benproductions1
Thank you, this gives me great hope!
Although it would be beneficial to have C# for things such as callback functions (still haven't figured out function pointers other than anonymous functions), it's much more "comfortable" in Javascript for me.
Thanks again! You seem very active in these forums since you've given me great answers before.
Yea, UnityScript is missing a lot of the features of C#. I preffer the syntax in UnityScript too, but I need the more advanced C# features to work, so I use C#.
Glad I could help, I'm really not that active :)