I am trying to implement turning of front wheels in PyBox2D, for now, I was able to make it turn left/right but I am not able to stop it when the angle reaches zero (to make the car to go straight)
class Car:
def __init__(self):
creating of a car
def control(self)
if keyboard.is_pressed("a"):
Car.Suspensions[2].motorSpeed = -5
Car.Suspensions[3].motorSpeed = -5
if Car.Tires[2].wheel.angle != 0:
if -np.radians(5) <= Car.Tires[2].wheel.angle <= np.radians(5):
Car.Suspensions[2].motorSpeed = 0
Car.Suspensions[3].motorSpeed = 0
elif keyboard.is_pressed("d"):
Car.Suspensions[2].motorSpeed = 5
Car.Suspensions[3].motorSpeed = 5
if Car.Tires[2].wheel.angle != 0:
if -np.radians(5) <= Car.Tires[2].wheel.angle <= np.radians(5):
Car.Suspensions[2].motorSpeed = 0
Car.Suspensions[3].motorSpeed = 0
My goal is to stop turning when the angle of a wheel reaches zero or value similar to zero, but not on the beginning (sometimes when the angles are zero they do not move at all, and if possible I would like to make it independent from pressing key on a keyboard (moving those two nested if statements out of the if keyboard_is_pressed(hotkey) part did not help
I hope I made myself clear and thank you very much for any help
Aucun commentaire:
Enregistrer un commentaire