hey all.
I've implemented Norman Barrows recommendations with the time scale. If the 2 lots of 60 in the equation to scale the timedelta are the frame time then
I have it like this. but I had to also add the scale to the forces.
.
//we need to create a time scale to multiply with the fixed time step
//the current fixed time step is 1/30 = 0.03 due to floating point you get 0.029999999
//we need the max speed of the object unit of displacement is 1m = 1000.0
double scaledspeed = (m_dMaxSpeed * 1000.0) * timedelta * timedelta;
double DTScaled = (scaledspeed) * timedelta;
D3DXVECTOR3 avoidforce ;
//needed to add scaled force to the steering is the correct?????????
m_vSteeringForce = Steering->Calculate() * scaledspeed;
//Acceleration = Force/Mass
D3DXVECTOR3 acceleration = m_vSteeringForce / m_dMass;
//update velocity
m_vVelocity += (acceleration)* DTScaled;// * timedelta);
//make sure vehicle does not exceed maximum velocity
m_vVelocity = Truncate(m_vVelocity, MaxSpeed());
//update the position
m_vPos += m_vVelocity* DTScaled;
This now allows me to use a mass greater then 2.0 So now my tank can have a mass as near to life like.
But also the Arrive function needed to be changed. The object was over shooting even though it was breaking(slowing down) before hand(before Time Scalepgrade).
It needed to be this, It sort of works
.
dist +=m_dMass;//add this because it was over shooting
double ramped_speed = MaxSpeed() * (dist / m_dRadius);
double clipped_speed = Min(ramped_speed, MaxSpeed());
D3DXVECTOR3 desired_velocity = (clipped_speed / dist) * ToTarget;
D3DXVECTOR3 r = desired_velocity - Velocity();
Some thing else I don't understand is the maxfoce.
Say you have a tank that has a mass of 5000.0 Kg and a max speed of 200km what should the max force be or do you play with this value.
Because some times the tank dosen't swing hard enough so I cranked up the force to no affect it was 180 set it to 100000.0 and no change.
The code is based on the book Programming Game AI by example By Mat Buckland(a must have for noobs).