Box2D Forums

It is currently Sat May 25, 2013 1:10 am

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Fri Mar 02, 2012 12:26 pm 
Offline

Joined: Thu Mar 01, 2012 9:31 am
Posts: 153
I have a car (body, 2 joints, 2 wheels) that moves, breaks fine. I'm wondering if it's possible to sync/match the 2 wheel's rotation or at least they appear to? I would like both to have the same angular velocity and rotation. My wheels extend the cirlce class.

Another possibly related question: hand brake. Is it possible to "lock" the wheels? When the car is braking, one or both wheels still rotate a little but I would like them to be non-rotating. I did try various damping/springs/joints but haven't found anything that would "lock" the wheels".


Last edited by IstvanOrosi on Sun Mar 04, 2012 9:36 am, edited 1 time in total.

Top
 Profile  
 
PostPosted: Sun Mar 04, 2012 9:35 am 
Offline

Joined: Thu Mar 01, 2012 9:31 am
Posts: 153
The first part was mostly a "visual" question and may or may not look for a solution where the wheel movements are synchronized. I'll have to see the final game. If I can't find a suitable solution then I'll just "mask" the wheels and create fake rotation :D

However, for the immediate braking, I prefer actual physics. Applying impulse could immediately stop an objects movement but the current box2d version (WCK) seem to have function only for linear movement but not rotation. I even thought about adding an object with joints to stop wheel rotation. After reading about being able to create rigid bodies by adding objects to another object, I added two "wheels" to the body of the car and that seemed to work fairly well. The issue was that I either had to make the new wheel radius somewhat larger so that the actual wheel doesn't touch. Another way would've been to completely remove the wheel (and joint) but these methods seemed "too much work". I had a feeling that there was something simpler. After some more reading/exploring, I found the fixedRotation property. Actually, I saw it earlier as the answer to keeping certain game characters upright, but it got lost within the many new features of Box2D/WCK. It worked almost perfect but in come cases the wheels kept rotating (though now in a continuous manner). That was solved by setting the wheel's angularVelocity to zero.... and done. Looks exactly the way I wanted it :)
Of course, when the car isn't braking, you have to turn off fixedRotation.

Lots of great stuff ... just have to find them. :)


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

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 0 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