Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Variable number of vertices in physics POLYGON and CHAIN

edited August 2013 in Suggestions Posts: 6

You should really add a possibility I will explain in an example.

What we have now

myBody = physics.body( CHAIN, loop,
vec2(15,10) )

What we can't do now, but is extremely easy for you to implement and is really important for dynamic games. I have no clue why you haven't implemented such a possibility already.

a = {

myBody = physics.body( CHAIN, loop, a )



  • edited August 2013 Posts: 2,054

    If you do myBody = physics.body(CHAIN, loop, unpack(a) it will work

  • edited August 2013 Posts: 1,976

    Yes, unpack() can return a bunch of variables that were in a table. If you look in the Physics Lab example you will see its use in function createRandPoly().

    Also, the physics API is Box2D, a separate library developed by other people, so we can't change it.

  • edited September 2013 Posts: 6

    Oh, didn't know there was such a thing as unpack(). Other languages I know well (c, c++, php, javascript) don't have similar functionality (as far as I know at least). I like this feature of Lua though. As for "we can't change that", I guess, you probably can add that by using this unpack, but probably better just add an example with unpack into documentation. I looked into Phys Lab example, but didn't find that unpack at the time I was searching for it. I'm pretty sure most people won't as well.

Sign In or Register to comment.