Page 1 of 1

vehicles

Posted: Thu Jan 24, 2013 11:35 pm
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!

Re: vehicles

Posted: Fri Jan 25, 2013 11:37 am
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.