Physic multi element bodies

Hi all guys,

I need some help, i d like to draw a line and then make it become a dynamic physic body . I ve been triying for a week but cant really get a solution. The problem is not about drawing the line the problem is about the physic.

If i a draw the line with display.newline and i use line:append, i can apply the physic body but it must be static.

if i do a series of circles and put it in a display group, when i add the physic body to the group the pshyic body isnt a line but a square or a rect.

If i create single circles and then i use weld joint to block them with the next one, the joint isnt strong enough to keep the line of circles rigid. it becomes a worm-like.

if i try to create a polygon i store every x and y in an array when Phase==moved then when phase== ended  reverse this array and add it to the other array creating the outline of my shape. the shape is invalid because there is a hole or the points are doubled (is this cause it has too many points?)

I m thinking about creating a physic multi element body dinamically my answers are :

is it possible? to create adding N shapes to my phisic body?how can i do it?

The methods i ve tried are coded bad or are just impossible?

is there another way to do this? Thank you for your help. (is this a newbe question?)

Hi @massimofortarezza,

There are a couple different approaches that I can suggest to solve this:

  1. Use the drawing of a line + line append, but instead of adding a physics body to the line object, create a thin rectangle which basically spans the gap between “points” along the line. This would take a little math to figure out the position/angle of the created rectangle, but nothing insane (just basic trigonometry).

  2. Use an “edge shape (chain)” body, which lets you create a physics body along a line edge. The limitation here is that you’d need to wait until the line was finished drawing, because you can’t “append” segments to a chain shape as you go along. Also, it’s limited to 32 vertices, so your line would need to stop at that point (or you’d need to start drawing a new edge shape).

https://docs.coronalabs.com/guide/physics/physicsBodies/index.html#edge-shape-chain-body

Hope this helps,

Brent

Hi @massimofortarezza,

There are a couple different approaches that I can suggest to solve this:

  1. Use the drawing of a line + line append, but instead of adding a physics body to the line object, create a thin rectangle which basically spans the gap between “points” along the line. This would take a little math to figure out the position/angle of the created rectangle, but nothing insane (just basic trigonometry).

  2. Use an “edge shape (chain)” body, which lets you create a physics body along a line edge. The limitation here is that you’d need to wait until the line was finished drawing, because you can’t “append” segments to a chain shape as you go along. Also, it’s limited to 32 vertices, so your line would need to stop at that point (or you’d need to start drawing a new edge shape).

https://docs.coronalabs.com/guide/physics/physicsBodies/index.html#edge-shape-chain-body

Hope this helps,

Brent