Hi guys! There is Box2D C# port: http://code.google.com/p/box2dx/ I want to use it in Unity, but one problem: this version uses unsafe-code and pointers, and Unity denies compile unsafe-code. Unsafe code is present in only 3 classes on this port: Distance.cs, TimeOfImpact.cs, ContactSolver.cs. For example: Code (csharp): internal unsafe void ReadCache(SimplexCache* cache, Shape shapeA, XForm transformA, Shape shapeB, XForm transformB) { Box2DXDebug.Assert(0 <= cache->Count cache->Count <= 3); _count = cache->Count; SimplexVertex** vertices = stackalloc SimplexVertex*[3]; ... ... } I don't have much C#-experience to change this classes and compile it for Unity3D. Any ideas? I know, many people want to use Box2D in their projects. P.S. Sorry for my English Cheers, Max.
just take out the unsafe and the pointers and it should work. and Im assuming cache is an array so take out the -> and just put a period
i think theres an option somewhere in unity that will let you use unsafe code. I dont remember where though. And it wont work on web build
Interested in hearing unsafe was once posible in 2.2. Any reason its not in 3? and is there a way to get /unsafe in 3.4? Crash-512: if its only a few spots where unsafe code is used, try no-pasting them and i'll see what i can help you with.
potentially unsafe code got removed to get rid of the pro limitation cheaters beside the fact that unitys native code support is limited to the InteropServices related stuff in pro and likely has some modifications on the compiler level in unity (unity is no stock mono in u3 far less than already in u2)
I created a simple integration of box2d to Unity few month ago, but development stopped. Someone interested in this development?
I tried many different b2d ports and the easiest to get it to work was box2dx. I just placed their dll on my assets folder and added the appropriate "using" keyword to whatever I needed from it. Only issue is that this port is based on an older box2d version, 2.01, I believe. But so far everything seems to be working fine for me.
I dont understand, I put the dll called Box2DX.dll in the assets folder and make a c# file with "using Box2DX;" line. but I still cant use any box2d class , why?
Up, anybody help me to use the dll file? here's bod2dx http://code.google.com/p/box2dx/downloads/detail?name=Box2DX-2.0.1.3-r175-RC-DemoSuite.zip&can=2&q=
I just found the way to use box2dx in unity3d. the problem for me now ,is to render the world in unity. hope PAX can help us lol
rex170, just use refactoring to change name of following classes: Vector2, Vector3, Joint. Also, PAX uses farseerPhysics too
so , can it be used easily like builtin physics engine in unity3d? like just add a body component to a object then works? can you teach me how to get started?
Hi, i've just come across this, thanks for posting the sources - very cool. I've noticed there is no interpolation option on dynamic bodies as there is with PhysX. I'll look to add that myself but I was wondering if anyone has done anything similar, or if there is another way to help sync physics with framerate? Thanks.
thank you for sharing the source. But how can I query collisions? such as raycast, OnCollisionEnter, OnTriggerEnter...
As far as I could tell the collision callbacks aren't exposed in the port so you'd have to implement that yourself. Be aware that Farseer/Box2D uses a different structure for the callbacks so it might be fair bit of work to get it to match Unity's way of doing things. Only one way to find out though