Stunt Playground - Vehicle Class and Setting Throttle

gzmzhen

18-08-2006 18:02:27

I want to use something very similar to this vehicle class, however instead of just using the arrow keys (or any digital keys for that matter) I want to allow the vehicle to be controlled by analog inputs (such as a steering wheel).

Is it possible for this setup? Like, is there a max throttle value that can be mapped from the anolog values to simulate driving in a real car? (where you push the gas pedal only so far to maintain the same speed on a flat road)

Thanks,
Nate

walaber

19-08-2006 02:56:09

I believe the Stunt Playground class accepts a float for the throttle setting, 0 = no throttle, 1 = full throttle, so 0.5 = half, etc.

you should be able to hook up analog control to it.

gzmzhen

19-08-2006 19:08:17

Since I posted this I did a little testing.

First, when you push the up key in stunt playground it makes the throttle 2.0 and then if you also push left_shift it multiplies the throttle by two (making it a max of 4). So I wasn't sure (am not quite still sure) if 1.0 is a max or not. I'll probably sift through the Vehicle class to do some more looking.

Also, I changed the throttle from 2.0 to 0.5 and the same max_speed is achieved about 41.0 units per second, however it just takes longer for that maximum to occur. If it were to work on an analog scale then 0.5 would round off to some value where the acceleration of the car is equal to the wind resistance (or other frictional forces occuring within the vehicle, and its individual components', motion).

Ahh, that actually makes me want to ask this: is there such a frictional force caused by air automatically? If not, are there easy ways to make this?

I'm fairly convinced that the steering has a domain of [-1, 1].

Another thing I was going to ask is about the braking. I see that either the brakes are on, or they're off. My steering wheel allows the use of analog breaking - do you see a possibility in increasing this as a capability?


Thanks for your time Walaber. I'm really impressed with your wrapper work and the available StuntPlayground source code to learn from (and the reusability of the vehicle class code which I'm hoping to use with some modifications).

Nate

walaber

19-08-2006 22:19:25

you can scale throttle as high as you want... but it was designed to 1.0 = full gas on. however, i found that all of the cars were underpowered, so rather than fix the torque curves for all of the cars, I just set the throttle to 2.0 :)

Stunt Playground doesn't simulate wind resistance, but you should be abe to fake it by applying a force against the current velocity, based on the current speed.

brakes can be analog as well. what you would do, is scale the "maxtorque" that the is passed to Newton, from 0 to whatever the strength of the brakes is. should be very simple to add.