collision and getlinearvelocity

Hello,

I try to make multiplayer game.
In the world i have three ball(circleshape). One for kick(kicker) and others for ball. kicker has mousejoint.
If I kick the any ball, other ball must make same motion.
-i use box2d 2.1-

I tried this;

Code: Select all

public class CustomContactListener extends b2ContactListener
   {
   override public function EndContact(contact:b2Contact):void
      {
         ........
         bll2.setLinearVelocity(bll1.getLinearVelocity);
      }
   }
}


and I tried this;

Code: Select all

public class CustomContactListener extends b2ContactListener
   {
   override public function PostSolve(contact:b2Contact, impulse:b2ContactImpulse):void {
      {
         ........
         bll2.setLinearVelocity(bll1.getLinearVelocity);
      }
   }
}



but they dont move same. Second ball move less then first. I can't take correct value of Linearvelocity.

Is there any way to take correct value or make something else?
GetLinearVelocity() is a function, not a variable. So to get the linear velocity, you do:

Code: Select all

bll1.GetLinearVelocity()


Also, just to be sure, make a copy of it, so for your code, it would be something like:

Code: Select all

bll2.SetLinearVelocity(bll1.GetLinearVelocity().Copy);


Also, be sure that you set your contact listener to the world. -]
my contact listener also seted to the world, i try bll1.GetLinearVelocity().Copy, but same problem.
saricizgi wrote:my contact listener also seted to the world, i try bll1.GetLinearVelocity().Copy, but same problem.

Oh whoops, I meant "bll1.GetLinearVelocity().Copy()".
Oh whoops, I meant "bll1.GetLinearVelocity().Copy()".


🙂 i also use like this,

Original thread: https://box2d.org/forum/viewtopic.php?t=8325