- 1. Specify a direction of vehicle movement and set resulted value to self.move_dir ('1' if vehicle moves forward, '-1' if vehicle moves backward, '0' if velocity is null).
- 2. Specify a direction of traction force of vehicle. Signs of resulted values coincides to self.move_dir`s ones and set to self.tracf ('1' if 'up' key pressed, '-1' if 'down' pressed, '0' if otherwise).
- 3. Check if velocity vector length is between 0 and 0.4, set self.move_dir to null.
- 4. Calculate a 2d vector of the traction force.
- 5. Calculate friction factor of surfaces of those nodes which are under each of four vehicle wheels and find out a maximum one of them.
- 6. Calculate an unit vector of velocity.
- 7. Calculate a friction force and its vector by multiplying the unit one by the friciton force.
- 8. Calculate resistance force of air and its vector doing it as in the previous step.
- 9. Add all those vectors (traction force, surface friction force and air resistance force) and divide by vehicle mass.
- 10. Set resulted acceleration.
Additionally, calculate rotation of wheels in the same functon:
- 11. Calculate an angle velocity by dividing velocity vector length by wheel radius and set it in self.object:set_rotation() as 'x'.
Download for testing: https://github.com/Andrey2470T/adv_vehicles2