- Home /
How to use Farseer Physics (C# Package) in Javascript?
I've downloaded Farseer Physics for Unity and imported it into a new project. Farseer is a C# / Unity port of a 2D physics engine based on Box2D.
There are many new classes such as Fixture and Body, but I cannot declare them in Javascript like:
var fixture :Fixture; // does not work.
Please help.
I have used Farseer but only with c#, presumably it could be related to Script compilation order issue. You could try putting all the farseer related stuff into a folder called plugins
Thank you for your help. I will try it when I get home and let you know.
I think it was downvoted because I asked a separate question yesterday about whether or not it's even possible to use Farseer in Javascript ins$$anonymous$$d of C#. I figured it's a different question, so I'd ask it in a different "Question."
Ok... I've been looking at google for hours trying to figure out where "Standard Assets" is since my project folder didn't have one. I made one inside the project folder myself after importing the package and when I tried to create components from the editor it just didn't work. $$anonymous$$ept throwing errors.
Am I missing something?
The exact error I'm getting is "...
Instance of FSShapeCpEditor couldn't be created. The script class needs to derive from ScriptableObject and be placed in the Assets/Editor folder.
'''"
Answer by ArkaneX · Sep 13, 2013 at 02:24 PM
I'm unable to download this package at the moment, but I was able to look at the oldest GitHub version, and classes there are in namespaces. If classes in Asset Store version are in namespaces as well, and I think they are, then you have to import namespace first. For example, both Fixture and Body are in namespace FarseerPhysics.Dynamics, so you need
import FarseerPhysics.Dynamics;
on top of your script.
In addition, if this package is not imported into Standard Assets folder (or any other folder which is compiled before your main scripts), then you can't access C# classes from JavaScript by default. To fix it, package content has to be moved to Standard Assets or Plugins folder.
EDIT: converted to answer.
Your answer

Follow this Question
Related Questions
NGUI Change animation method 2 Answers
My Health Script Won't work in C# 1 Answer
How to use Android Dual Joysticks? 1 Answer
Using PlayerPrefs to transfer variables from Javascript to C# 1 Answer
Unity reboots my computer 1 Answer