Physics and joints (DEF-3025)


#1

Are there any plans to adding joints into physics engine?
Just want to porting some old stuff from Flash to Defold such as:


#3

There is currently no plan for this, but we’ve said that we want it many times :confused:
I added the ticket DEF-3025 for this.


#4

So I can’t make a car physics. And it’s impossible to develop games like Earn to Die, Moto X3M, Hill Climb Racing, Happy Wheels etc…


#5

Not impossible. For example, someone could make a Box2D native extension with all of the features.


#6

It’s not an easy, because we have no access to buffers with game components like transform, physic shapes data etc.
For now it will have big overhead for communication like lua->NE->lua->Engine every frame.
It would be great if Defold developers made this buffers accessable using Defold SDK.


We do not even have possability to read vectors (user types: vector3, vector4, matrix etc) on NE side (using Defold SDK) but we talked about this with @Mathias_Westerdahl and I hope for a soon improvements here.


Default engine types in Defold SDK (DEF-3407)
#7

Car physics can be implemented in Lua, should not be too hard. Check out this javascript version, for instance: https://github.com/spacejack/carphysics2d


#8

It’s not exactly what @notbadgun meant. Moto X3M:


#9

That is also possible, but takes more work, of course.


#10

Here’s a unity version that looks nicer. It’s ported from the same physics code: https://github.com/jongallant/CarSimulator


#11

Any news?
Currently Defold can’t be used to remake any physics Flash games.


#12

No news. We still want to improve the Box2D support, but other things have been given higher priority.

We do also plan to move Box2D and Bullet into native extensions. That way developers can fork and expose more parts of the API (although without nice editor bindings).

For now, an alternative would be to use your own physics extension. I started a Chipmunk2D extension a while back, but it’s not finished yet:

Forum post: Box2d update
HTML5 demo: https://britzl.github.io/Chipmunk2D

Note that this extension doesn’t give you any editor integration so you need to set things up via code. I wonder if there’s some external tool to create complex physics objects with bodies, joints, springs etc?

What kind of joints would you say are the most important to implement first?


#13

There’s this https://www.iforce2d.net/rube/ http://www.iforce2d.net/forums/viewtopic.php?f=6&t=240


#14

Yes, that’s exactly the kind of tool I was thinking of. And it has a simple json file format!


#15

So awesome!

It’s okay! But is it possible to get shapes of collision objects via code as I see them in editor?

For games like Mining Truck the most important are b2RevoluteJoint and b2PrismaticJoint (Box2D naming).


#16

No, you need to create everything through code. You cannot set anything up in the editor. And the extension maps the Chipmunk API, nothing more. You can however build a Lua wrapper on top of it that binds the created Chipmunk bodies to game objects and keeps them automatically update (like dynamic collision objects in Defold). This is what I do in the example.

I believe both of these have Chipmunk 2D equivalents.