bharling
20-04-2007 01:20:45
Can't figure out how this works (from the newton vehicle demo):
I'm trying to implement a callback to make a character walk (or more specifically, apply torque to the sphere representing the feet) when a key is pressed. How and where could I assign a callback to do that?
I understand the vehicle example where torque and steering are stored and applied on the callback, just not how the engine knows which callback to use. Also, is it possible to assign multiple callbacks, ie: walkforward, turn etc. to different keys (or events)? or is it best to store these values and just apply them in one callback.
many thanks for any responses
## This is the important callback, which is the meat of controlling the vehicle.
def userCallback(self):
## foop through wheels, adding torque and steering, and updating their positions.
## problem here as the original source casts the tire returned as a simpletire
## however getFirstTire returns and OgreNewt tire so we lose the 'steering'
for tire in self.tires:
if (tire.SteeringTire):
tire.setSteeringAngle( self.Steering )
else:
tire.setTorque( self.Torque )
## finally, this command updates the location of the visual mesh.
tire.updateNode()
I'm trying to implement a callback to make a character walk (or more specifically, apply torque to the sphere representing the feet) when a key is pressed. How and where could I assign a callback to do that?
I understand the vehicle example where torque and steering are stored and applied on the callback, just not how the engine knows which callback to use. Also, is it possible to assign multiple callbacks, ie: walkforward, turn etc. to different keys (or events)? or is it best to store these values and just apply them in one callback.
many thanks for any responses
