Twin bodies

Sep 7, 2008 at 7:42 PM

Another problem, another thread :). So, this time I have to clone one body. Let's say B is clone of A. They have to 'share' same forces, velocity, etc. For example when A is being hit by some object, force has to apply also to body B, and vice versa - B hit, A also taking hit. It's not complicated from A=>B, but A<=>B is harder...
Sep 9, 2008 at 2:48 PM
@garus - So you want to have 2 bodies react to everything the same, but have different positions? The best way to o something like that would be to simply add an offset to the position of the first body when your drawing. I believe you can have 2 geoms for the same body but don't hold me to that. Please give some more details as to the purpose of the cloning.
Sep 9, 2008 at 4:04 PM
I'm making Portals (like in Valve's Portal). Not very original idea, but it's kind of a challange for me ;) So, when body A is entering portal, I clone it and set clone's position on position of exit portal. This way both are physical objects and when clone meets obstacle, collision also affects original body.
Sep 9, 2008 at 6:28 PM
@garus - Ok, so will you be adjusting the direction of the velocity like Portal does? Will all portals be on the same screen? I'd say your best bet would be to would be to just manually offset the position of a single body and maybe rotate the velocity of the body to match the orientation of the portal. So no cloning, just as your body collides with a portal change it's position to the output portal.
Sep 9, 2008 at 7:09 PM
Edited Sep 9, 2008 at 7:16 PM
Yes, that's even more simple, but what about situation when body is partially inside first portal and partially outside second portal? That's why I need cloning.
Sep 9, 2008 at 7:54 PM
I see, well in that case maybe you should just add another geom at the other portals position at the time of impact and then remove the first geom after the impact is over. Of course you couldn't change the velocity at all but if you don't need that it wouldn't be to hard. Or you could write your own copy constructor to copy all the variables and then just update the position to the new portal.
Sep 10, 2008 at 4:27 AM
I will try both solutions. Thanks for your help ;)