Body Stops Interacting After Being Recreated

Hi all,

I’m making a gear puzzle where the player needs to connect differently sized gears in the proper order across screen.  The far-left gear is using a pivot joint and a motor, so spins continuously.  End-game is making gear on far-right spin.

I have the gears snapping to predefined “axles” on the screen.  When a gear snaps to an axle, I recreate the physics body (to change the groupIndex), create a small static rect at the X & Y of the axle (anchor is centered), then create a Pivot joint between the gear and the static rect.

As soon as the gear snaps, 9/10 times it stops interacting with the main wheel, that is until I touch the gear with one of the other gears.  Below is a GIF of the problem. 

https://gyazo.com/8e224698818dedc7ded1b313afd3c62e

I have confirmed that a collision is registered between the motor-gear and the placed-gear as soon as the new body is created.  

Any idea what’s causing this? 

Maybe the gear is sleeping.  Try setting this to false after adding the body:  https://docs.coronalabs.com/api/type/Body/isSleepingAllowed.html

Thanks for the reply.  Tried your suggestion and still the same, inconsistent behaviour regardless of isSleepingAllowed value. 

One thing that may be of interest is that even though the gear touching the motor isn’t moving at all, it still never sleeps. 

Note, in GIF below isSleepingAllowed=true for all objects:

https://gyazo.com/fb9fff0e2bba1c08c18513058c407a2b

This GIF shows how inconsistent the behaviour is:

https://gyazo.com/2e084f08e44b99a33eb34666e1fea6e2

I thought about capturing angular momentum of the original body and assigning to the recreated one, but this seems hackey and gravity/drag + other gear interactions are likely to cause the original gear to stop anyways.

I’ve also tried increasing friction of all gears to 100 and increasing radius of each gear to make sure gears have full contact.  Neither fixed the issue.

Bump.  Anybody?

Can’t really say i figured out the problem in the OP, but using a Gear joint makes the gears spin as they should.

Maybe the gear is sleeping.  Try setting this to false after adding the body:  https://docs.coronalabs.com/api/type/Body/isSleepingAllowed.html

Thanks for the reply.  Tried your suggestion and still the same, inconsistent behaviour regardless of isSleepingAllowed value. 

One thing that may be of interest is that even though the gear touching the motor isn’t moving at all, it still never sleeps. 

Note, in GIF below isSleepingAllowed=true for all objects:

https://gyazo.com/fb9fff0e2bba1c08c18513058c407a2b

This GIF shows how inconsistent the behaviour is:

https://gyazo.com/2e084f08e44b99a33eb34666e1fea6e2

I thought about capturing angular momentum of the original body and assigning to the recreated one, but this seems hackey and gravity/drag + other gear interactions are likely to cause the original gear to stop anyways.

I’ve also tried increasing friction of all gears to 100 and increasing radius of each gear to make sure gears have full contact.  Neither fixed the issue.

Bump.  Anybody?

Can’t really say i figured out the problem in the OP, but using a Gear joint makes the gears spin as they should.