Change center of mass for rotations on physics objects.

I’d like to change the center of rotation on the physics objects of my circles, so that they sway back and forth… Is there a way to do this with a physics object? Or do I need to use transition.to and some logic to make the rotation go back and forth? I hope I laid the situation out clearly…
Thanks!

-Jake [import]uid: 144504 topic_id: 33310 reply_id: 333310[/import]

Hi Jake,

I want to picture your situation a little better, especially what you mean by wanting to make the circles “sway back and forth”. Do you mean swaying back and forth like at the bottom of a pendulum? Or do you mean swaying back and forth like a tire would on the ground if there were some weights inside just part of the rim? Or maybe you mean something different from either of these?

Depending on your situation, there’s certainly a way to accomplish this with either joints (pivot joints, in particular) or a complex physics body consisting of your circle plus an additional off-center weight (to create an overall off-center center of mass for the object).

  • Andrew [import]uid: 109711 topic_id: 33310 reply_id: 132293[/import]

I would attach an invisible and very dense object off-centre to you object with a weld joint. That’s the simplest way I can think of shifting an object’s centre of mass. [import]uid: 8271 topic_id: 33310 reply_id: 132302[/import]

Yes, the pendulum, that is a much better illustration… I thought maybe there was a property that let me change the center but I guess not… Maybe a center of rotation property should be added to Corona. haha anyways I’ll see if I can implement that. Thank you!! [import]uid: 144504 topic_id: 33310 reply_id: 132305[/import]

This might be the simplest solution, I don’t think it would work in my situation the best, I’m not sure… I’m spawning several of the circles one after the other, then after a period they are destroyed… So maybe that would not be best for joints to be attached then detached so quickly…

Thanks! [import]uid: 144504 topic_id: 33310 reply_id: 132306[/import]

Reuse your objects if you want to avoid the overhead of CRUD operations… If you are creating and destroying them often why not create a set number at the start and when you want to destroy one simply make it invisible and turn off its physics body (.isVisible, .isBodyActive) then move it to where you need a new one and switch it back on. [import]uid: 8271 topic_id: 33310 reply_id: 132309[/import]

Hi Jake,

I want to picture your situation a little better, especially what you mean by wanting to make the circles “sway back and forth”. Do you mean swaying back and forth like at the bottom of a pendulum? Or do you mean swaying back and forth like a tire would on the ground if there were some weights inside just part of the rim? Or maybe you mean something different from either of these?

Depending on your situation, there’s certainly a way to accomplish this with either joints (pivot joints, in particular) or a complex physics body consisting of your circle plus an additional off-center weight (to create an overall off-center center of mass for the object).

  • Andrew [import]uid: 109711 topic_id: 33310 reply_id: 132293[/import]

I would attach an invisible and very dense object off-centre to you object with a weld joint. That’s the simplest way I can think of shifting an object’s centre of mass. [import]uid: 8271 topic_id: 33310 reply_id: 132302[/import]

Yes, the pendulum, that is a much better illustration… I thought maybe there was a property that let me change the center but I guess not… Maybe a center of rotation property should be added to Corona. haha anyways I’ll see if I can implement that. Thank you!! [import]uid: 144504 topic_id: 33310 reply_id: 132305[/import]

This might be the simplest solution, I don’t think it would work in my situation the best, I’m not sure… I’m spawning several of the circles one after the other, then after a period they are destroyed… So maybe that would not be best for joints to be attached then detached so quickly…

Thanks! [import]uid: 144504 topic_id: 33310 reply_id: 132306[/import]

Reuse your objects if you want to avoid the overhead of CRUD operations… If you are creating and destroying them often why not create a set number at the start and when you want to destroy one simply make it invisible and turn off its physics body (.isVisible, .isBodyActive) then move it to where you need a new one and switch it back on. [import]uid: 8271 topic_id: 33310 reply_id: 132309[/import]