Vector math problem

BlitzMax Forums/BlitzMax Programming/Vector math problem

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Game Physics really isnt something Ive done much in so hopefully someone else here will be able to point you in the right direction for something a bit more realistic.

If I had to have a stab at a simple simulation Id probably try something like this.

1. If accelerating then apply an acceleration force to the tank.

2. The tank naturally wants to stop so every frame apply a friction force to the velocity.

I guess the friction force should increase with speed. In order to cap the total speed of the tank you want the friction force to be equal to the acceleration force when the velocity is the top speed.

so.. a simple first stab if the acceleration is 10 and max speed is 50 then friction could be velocity / 10.

so each frame you have the current velocity vector. You add the acceleration vector to it then reduce the length of the veolcity vector by the friction.

Hopefully this would mean the tank would accelerate fast at first and slow down as it approaches the max speed.
If a force of 200 hits the side of the tank when it is moving at max then you can carry on applying the acceleration vector to the velocity vector but the friction would ensure the total velocity would keep dropping until you reach normal forward motion.

Of course the above friction formulae is not very good so youd have to come up with something better.. maybe something like
1. If velocity < 50 then friction = 5
2. if velocity >= 50 then friction = 5+(velocity-50)*(velocity-50)

I dunno Id keep playing around till the results looked pleasing to the eye.

Anyway.. thats my mindless thoughts.. hopefully soon someone else who knows about these things will give you a better solution.
Good luck with it.