Box2D Forums

It is currently Fri May 24, 2013 6:02 pm

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: Fri Mar 30, 2012 12:54 am 
Offline

Joined: Fri Mar 30, 2012 12:41 am
Posts: 3
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:
public class CustomContactListener extends b2ContactListener
   {
   override public function EndContact(contact:b2Contact):void
      {
         ........
         bll2.setLinearVelocity(bll1.getLinearVelocity);
      }
   }
}


and I tried this;
Code:
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?


Top
 Profile  
 
PostPosted: Fri Mar 30, 2012 2:37 am 
Offline

Joined: Sun Oct 25, 2009 3:28 am
Posts: 242
GetLinearVelocity() is a function, not a variable. So to get the linear velocity, you do:
Code:
bll1.GetLinearVelocity()


Also, just to be sure, make a copy of it, so for your code, it would be something like:
Code:
bll2.SetLinearVelocity(bll1.GetLinearVelocity().Copy);


Also, be sure that you set your contact listener to the world. -]


Top
 Profile  
 
PostPosted: Fri Mar 30, 2012 4:03 am 
Offline

Joined: Fri Mar 30, 2012 12:41 am
Posts: 3
my contact listener also seted to the world, i try bll1.GetLinearVelocity().Copy, but same problem.


Top
 Profile  
 
PostPosted: Fri Mar 30, 2012 4:23 am 
Offline

Joined: Sun Oct 25, 2009 3:28 am
Posts: 242
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()".


Top
 Profile  
 
PostPosted: Fri Mar 30, 2012 4:37 am 
Offline

Joined: Fri Mar 30, 2012 12:41 am
Posts: 3
Quote:
Oh whoops, I meant "bll1.GetLinearVelocity().Copy()".


:) i also use like this,


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group