vehicles

General discussion about Box2D tutorials
Post Reply
vkreal
Posts: 66
Joined: Sun Jan 13, 2013 7:29 pm

vehicles

Post by vkreal »

Hi iforce2d,

I was studying your code vehicles_bike.js that comes with RUBE. I wanted to know why you are using SetAngularVelocity to update the motor speed instead of using SetMotorSpeed and SetMaxMotorTorque. What's you recommendation to use for a bike game with terrain?


Thanks!
iforce2d
Site Admin
Posts: 861
Joined: Sat Dec 22, 2012 7:20 pm

Re: vehicles

Post by iforce2d »

There are a number reasons.
- instant feedback for player feels easier to control
- easy to tune acceleration and max speed
- joint torque affects both connected bodies, so the main body of the bike is affected as well, especially noticeable when bike is jumping in the air. This can be minimized by making the wheels a much smaller mass, but requires a lot of fiddling to find a ratio of masses which doesn't twist the whole body, yet still keeps the wheels heavy enough to effectively move the bike.
- setting the velocity directly requires less calculation than a joint
- quicker

I was making that demo as one of many, especially if you consider all the others (Java, iOS, Chipmunk etc) so I could not afford to spend all that much time on it, but if you are making a more serious app you could find a nice combination of settings. I think it would give you a better feeling simulation overall.
Post Reply