Box2D lua bindings for Defold Game Engine.
Try to keep lua api same as c++ api when it possible.
I try to make extension as much production ready as possible.
I use test to make sure, that all worked.
195 tests 195 passed 4074 assertions 0 failed 0 errors 0 unassertive 0 pending
But i think it need some iterations with fixes, polishing and new bindings.
Any code review, pull requests, experiments are welcome
Let’s make using the full power of box2d in defold real.
Hello d954mas
It’s really wonderful what you have done! Thanks for sharing.
I tried before to implement “Conveyor belts” (tank) in Defold but couldn’t… I’ll give it a try with your extension very soon I hope. I’ll let you know…
Thanks again and don’t forget to add it as Defold Asset.
Thanks, i forget about it.
Make a request to add asset.
Amazing work @d954mas
I’m not an expert so sorry for my next question but this shouldn’t be within the Defold already? Like out of box?
I know extensions are a great feature of defold but idk just a question.
I test extension in windows and html.
It should work on other platforms too.
Test in my android, and it crashed(
Will make investigation later
Can you please check that it worked in:
1)ios
2)linux
3)mac
Defold alredy use box2d for 2d physics.
But it used somewhere in engine, and we have very limit control on how it worked.
With extension you will get full control.
Here a great answer about defold box2d and full box2d.
Oh interesting!
it makes sense. Thank you!
Awesome!
The demo project works fine on Linux here. I tested debug and release builds as well as build-and-run from the editor.
195 tests 195 passed 4074 assertions 0 failed 0 errors 0 unassertive 0 pending
The local varaible BOX2D_UTILS in dominos_scene.script is empty. Do you intend to keep it empty?
Yes, BOX2D_UTILS .debug_draw variable was created in other place.
Create get_debug_draw function. Now it looks better.
Thanks:)
Fixed android build.
The problem was with dump function.
It try to create file but can’t.
Also disable it for ios, i think it can have same problem.
static int Dump(lua_State *L){//void Dump()
utils::check_arg_count(L, 1);
World *lua_world = World_get_userdata_safe(L, 1);
#if !defined(DM_PLATFORM_ANDROID) && !defined(DM_PLATFORM_IOS)
lua_world->world->Dump();
#else
dmLogWarning("Dump not supported on mobiles");
#endif
return 0;
}
Windows, linux, html, android worked.
Mac and ios need tests. Need help with that.
Thanks
This is amazing - v2.4.1, the latest version!
I haven’t yet played with it, but I’m guessing this doesn’t tie in with any of the built in Defold components? Ie, a world from the Box2D extension interacting with a world from a Defold collection proxy?
To tie game objects to a Box2D body, would you have to set the position manually? Would this lag a frame behind?
Sorry for the barrage of questions.
macOS Big Sur v11.4, tests passed.
It can’t work together with defold 2d physics.
You should remove defold engine box2d in appmanifest.
So this extension can’t interacting with defold components.
All physics you set manualy in code.
Yes.
You get position from body.
Then set position to go.
go.set_position(body:GetPosition())
About frame lag.
This topic?
Dealing with the one frame lag when visualising dynamic bodies - #6 by Mathias_Westerdahl
if i understand correctly problem happened because script update is called before physics update?
In this extenstion you update physics manualy in script.
function update(self, dt)
self.world:Step(1 / 60, 8, 3)
self.world:DebugDraw()
end
Also you always get actual possition by body:GetPosition()