I am very new to box2d, can anyone give an ideas/suggestions on how to tilt a vehicle(motorcycle) up/down when in the air?
Thanks!
Tilting vehicles
Re: Tilting vehicles
You can use a small ApplyTorque to turn the main body.
Re: Tilting vehicles
iforce thanks for your suggestion. I am trying to balance a motorcycle on rear wheel simulating a wheely. The problem i am having is when using ApplyTorque not sure when to stop apply force to balance the motorcycle. any ideas? maybe ApplyTorque is wrong approach in this case.
Many thanks!
Many thanks!
Re: Tilting vehicles
Yeah it's a lot harder than they make it look on TV that's for sure. I could only ever do it for a few seconds, even when I had a bike that was quite good for wheelies. These days I just have a little scooter so it's not gonna happen at all with that.
oh... you were still talking about Box2D? I think the basic idea remains the same as in the topic here: http://www.iforce2d.net/b2dtut/rotate-to-angle
You need to look at the current angular velocity, as well as the current angle. If the body is already rotating toward the angle you want, then you can apply less torque.
oh... you were still talking about Box2D? I think the basic idea remains the same as in the topic here: http://www.iforce2d.net/b2dtut/rotate-to-angle
You need to look at the current angular velocity, as well as the current angle. If the body is already rotating toward the angle you want, then you can apply less torque.
Re: Tilting vehicles
awesome iforce! I will give it a try.
Re: Tilting vehicles
Hi Iforce2d,
I am trying to achieve same precise(smooth) using accelerometer In your game Downhill Supreme especially controlling player titling. can you give any pointers how to achieve this? i tried using http://www.iforce2d.net/b2dtut/rotate-to-angle but doesnt seem to work that great for me, maybe its the way i implemented it.
Thanks!
I am trying to achieve same precise(smooth) using accelerometer In your game Downhill Supreme especially controlling player titling. can you give any pointers how to achieve this? i tried using http://www.iforce2d.net/b2dtut/rotate-to-angle but doesnt seem to work that great for me, maybe its the way i implemented it.
Thanks!
Re: Tilting vehicles
iirc the method used in DHS is like "Using torques" in that tutorial topic, except that the size of the torque is taken from the orientation of the device. There is also a limit on the maximum torque that is applied, so that after the device is tilted more than 45 degrees or so it doesn't make any difference. There is also a minimum limit so that nothing will happen unless the device is tilted more than about 5 degrees, to make it easier for the player to hold the rotation constant. You will most likely need to use the average of the tilt value for the last 10-20 steps, to get a smoother value.