is it possible in Corona? walking simulation with physics and smooth movement

Hi,

I am trying to build a walking simulation of human character that controlled by user taps, similar to steppy pants (each tap make one step) but with smoother move and more physics and balancing involved.

is it possible to do with Corona? tricks/tools?

from my study looks best way is using spine, but spine with physics, not possible in Corona. 

Thank you

Not sure how complex you want the “body” to be, but you could attempt to assemble a ragdoll type of figure connected by physical joints. It could be prone to various issues however. Not sure Spine would really help in any case, since it would just control the visuals and not really take into account physical “balancing” and so forth.

Brent

Good timing regarding this issue. I have been doing some investigations on this functionality for a while now and have been in discussion with the esoteric SPINE team on how this might be possible in corona sdk. 

Brent, Your right regarding visuals and physics, but it seems like it is possible from discussions with spine guys.  However, there are some small constraints in the physics API to allow a tool like spine to simulate skeletal movement.  

You can see the following links to their forums and bugs/feature requests.    See these two links

http://esotericsoftware.com/forum/Corona-Help-to-position-bounding-box-on-a-bone-1855?p=32698#p32698

https://github.com/EsotericSoftware/spine-runtimes/issues/892

Essentially the issue seems to come down to:

The gist of it is that Corona’s physics API will center all shapes you add (!) which makes it almost impossible to compensate for. And even if you compensate for it, you then run into the problem of having to update the shapes every frame, which also means destroying and recreating them. I’m afraid we haven’t found a solution for this yet.

Brent, I made some suggestions of possible ways forward on the github issue (above), but i’m really shooting from the hip.  

Are you able to comment on this?    How difficult it might be to give physics/graphics API access to create shapes (polygons) without automatically being centred. Or can you see a workaround?

I can see many great games that could be built using this feature.  Steppy pants, daddy long legs being some successful ones to date. If this could be done without having to create your own physics system that would be a massive time saver. It would also continue to update the physics simulation to 

Thanks in advance

Hi @online2,

Does Spine actually “redraw” every single physical outline to match the visual appearance as the model animates, and do so every frame? For instance, if an “arm” stretches, is the physical bounaries of that arm supposed to warp/stretch along with the visual representation coming from Spine? From a Box2D standpoint, which of course Corona uses, I don’t see how this is possible without “re-creating the shape” every frame as the Spine runtime author indicates. I’ve never heard of Box2D being able to dynamically warp and modify shapes on the fly, as it’s a physics engine based on rigid bodies… so then, from Spine’s standpoint, I’m not sure how the other runtimes which use Box2D handle this (there is a wide list of runtimes they support, and some of those engines have Box2D at the core, just like Corona).

In terms of “centering”, it has always been possible to re-orient a polygonal body around a different point, by simply adjusting the vertices. Chain shapes can be done in a similar way, since they accept a series of vertices to draw the shape.

I’m curious to see where we can get with this, as Spine is an amazing tool, and you’re not the first person who has faced this issue. Keep me updated please…

Brent

Thanks for the reply Brent.     I have posted your reply on this thread on the esoteric forums. Lets see what Badlogic comes back with. 

Hi Brent! Thanks for the additional info. Let me try to clarify the problem a bit more.

Spine bounding shapes are arbitrary, non-self-overlapping, concave polygons that may vertex deform during an animation. As such, chain shapes would be a good fit to represent them via Box2D, so no problem there. We could optimize things a little by using simpler Box2D shapes when possible (concavity testing etc.). We obviously have to disallow vertex deformations as Box2D doesn’t support them. This means the shape is created once, and never modified afterwards.

Our bounding shapes are transformed using an affine local to world transform, expressed as a 2x2 matrix plus translation offset. That transform is derrived from the bone (and its parents) to which the bounding shape is attached. Since Box2D does not allow scaling or shearing of shapes, the transform may not include such sub-transform. That’s a hard limitation users have to be aware of. The transform may change every frame.

To apply the transform to the Box2D shape, I can either re-create the shape each frame using world coordinates (not an option!) or translate the transform into Box2D offset and rotation values and make sure the chain shape is a kinetic shape in Box2D (or static? forgot the name), so I can apply the transform to it. Simple enough.

Hm, it seems I just figured out what I can and can not do (vertex deform, scale, shear) by explaining it here :smiley: Thanks for your input, looks like it got my gears spinning in the right direction.

Hi @badlogicgames,

Awesome! If there’s anything else I can help with, let me know… I realize that while Box2D is at the core of Corona and also at the core of other platforms, there are some “tweaks” Corona might be doing over the core Box2D to make it work more harmoniously with Corona (some other engines like Defold have done minor customizations to their Box2D integration as well, to make it work more as they see fit).

Brent

FYI, in Box2D, “kinematic” is the body type which is not affected by forces (gravity, etc.).

Thanks for your input @badlogicgames and @brentSorrentino. I and i am sure others dealing with this issue really appreciate it.

(its @onine2 here now under the name @kadlugan -  which is my preferred handle - @online2 was what the forums system generated)

@badlogicgames, Thats great to hear that you’ve got your gears spinning in the right direction.  I’m really looking forward to where this could lead to.   I can foresee that you’ll probably going try to test out your thinking in a super basic mockup?

e.g. a pair of legs with big feet.

  __

 [__]

 /   \

 L   L

Or even a car with big ‘wheels’ (ie spinning round legs)

O-O

Another consideration might be to use the corona collision filters plugin API.   This way you can avoid the spine physics object interacting with itself, e.g. so that legs can overstep themselves, giving the appearance of depth, but interact with the ground.

Fingers crossed!

Hi, Guys, 
@kadlugan @brentSorrentino @badlogicgames

I’ve read your replies above many times, but I cannot find the answer,  :huh: 
is it possible? how ? what should I do?

I badly need this if you can please help, actually I start to look to unity, but I really hope it’s possible in Corona.

there is also option to pay for coding this, if anyone reading this interested.

Thank you

Not sure how complex you want the “body” to be, but you could attempt to assemble a ragdoll type of figure connected by physical joints. It could be prone to various issues however. Not sure Spine would really help in any case, since it would just control the visuals and not really take into account physical “balancing” and so forth.

Brent

Good timing regarding this issue. I have been doing some investigations on this functionality for a while now and have been in discussion with the esoteric SPINE team on how this might be possible in corona sdk. 

Brent, Your right regarding visuals and physics, but it seems like it is possible from discussions with spine guys.  However, there are some small constraints in the physics API to allow a tool like spine to simulate skeletal movement.  

You can see the following links to their forums and bugs/feature requests.    See these two links

http://esotericsoftware.com/forum/Corona-Help-to-position-bounding-box-on-a-bone-1855?p=32698#p32698

https://github.com/EsotericSoftware/spine-runtimes/issues/892

Essentially the issue seems to come down to:

The gist of it is that Corona’s physics API will center all shapes you add (!) which makes it almost impossible to compensate for. And even if you compensate for it, you then run into the problem of having to update the shapes every frame, which also means destroying and recreating them. I’m afraid we haven’t found a solution for this yet.

Brent, I made some suggestions of possible ways forward on the github issue (above), but i’m really shooting from the hip.  

Are you able to comment on this?    How difficult it might be to give physics/graphics API access to create shapes (polygons) without automatically being centred. Or can you see a workaround?

I can see many great games that could be built using this feature.  Steppy pants, daddy long legs being some successful ones to date. If this could be done without having to create your own physics system that would be a massive time saver. It would also continue to update the physics simulation to 

Thanks in advance

Hi @online2,

Does Spine actually “redraw” every single physical outline to match the visual appearance as the model animates, and do so every frame? For instance, if an “arm” stretches, is the physical bounaries of that arm supposed to warp/stretch along with the visual representation coming from Spine? From a Box2D standpoint, which of course Corona uses, I don’t see how this is possible without “re-creating the shape” every frame as the Spine runtime author indicates. I’ve never heard of Box2D being able to dynamically warp and modify shapes on the fly, as it’s a physics engine based on rigid bodies… so then, from Spine’s standpoint, I’m not sure how the other runtimes which use Box2D handle this (there is a wide list of runtimes they support, and some of those engines have Box2D at the core, just like Corona).

In terms of “centering”, it has always been possible to re-orient a polygonal body around a different point, by simply adjusting the vertices. Chain shapes can be done in a similar way, since they accept a series of vertices to draw the shape.

I’m curious to see where we can get with this, as Spine is an amazing tool, and you’re not the first person who has faced this issue. Keep me updated please…

Brent

Thanks for the reply Brent.     I have posted your reply on this thread on the esoteric forums. Lets see what Badlogic comes back with. 

Hi Brent! Thanks for the additional info. Let me try to clarify the problem a bit more.

Spine bounding shapes are arbitrary, non-self-overlapping, concave polygons that may vertex deform during an animation. As such, chain shapes would be a good fit to represent them via Box2D, so no problem there. We could optimize things a little by using simpler Box2D shapes when possible (concavity testing etc.). We obviously have to disallow vertex deformations as Box2D doesn’t support them. This means the shape is created once, and never modified afterwards.

Our bounding shapes are transformed using an affine local to world transform, expressed as a 2x2 matrix plus translation offset. That transform is derrived from the bone (and its parents) to which the bounding shape is attached. Since Box2D does not allow scaling or shearing of shapes, the transform may not include such sub-transform. That’s a hard limitation users have to be aware of. The transform may change every frame.

To apply the transform to the Box2D shape, I can either re-create the shape each frame using world coordinates (not an option!) or translate the transform into Box2D offset and rotation values and make sure the chain shape is a kinetic shape in Box2D (or static? forgot the name), so I can apply the transform to it. Simple enough.

Hm, it seems I just figured out what I can and can not do (vertex deform, scale, shear) by explaining it here :smiley: Thanks for your input, looks like it got my gears spinning in the right direction.

Hi @badlogicgames,

Awesome! If there’s anything else I can help with, let me know… I realize that while Box2D is at the core of Corona and also at the core of other platforms, there are some “tweaks” Corona might be doing over the core Box2D to make it work more harmoniously with Corona (some other engines like Defold have done minor customizations to their Box2D integration as well, to make it work more as they see fit).

Brent

FYI, in Box2D, “kinematic” is the body type which is not affected by forces (gravity, etc.).

Thanks for your input @badlogicgames and @brentSorrentino. I and i am sure others dealing with this issue really appreciate it.

(its @onine2 here now under the name @kadlugan -  which is my preferred handle - @online2 was what the forums system generated)

@badlogicgames, Thats great to hear that you’ve got your gears spinning in the right direction.  I’m really looking forward to where this could lead to.   I can foresee that you’ll probably going try to test out your thinking in a super basic mockup?

e.g. a pair of legs with big feet.

  __

 [__]

 /   \

 L   L

Or even a car with big ‘wheels’ (ie spinning round legs)

O-O

Another consideration might be to use the corona collision filters plugin API.   This way you can avoid the spine physics object interacting with itself, e.g. so that legs can overstep themselves, giving the appearance of depth, but interact with the ground.

Fingers crossed!

Hi, Guys, 
@kadlugan @brentSorrentino @badlogicgames

I’ve read your replies above many times, but I cannot find the answer,  :huh: 
is it possible? how ? what should I do?

I badly need this if you can please help, actually I start to look to unity, but I really hope it’s possible in Corona.

there is also option to pay for coding this, if anyone reading this interested.

Thank you