Vector based unit movement
23,938
2
Advertisement
Up to this point I have been using a unique code snippet for each direction of movement. These days I managed to switch to using vectors for movement. I have the same code for all directions now
float VectorX = NextNodeX - UpixPosX;
float VectorY = NextNodeY - UpixPosY;
float VecLength = sqrt(VectorX * VectorX + VectorY * VectorY);
float SpeedPercent = (0.016 * 100) / VecLength;
float AdvanceX = (VectorX * SpeedPercent) / 100;
float AdvanceY = (VectorY * SpeedPercent) / 100;
UpixPosX = UpixPosX + AdvanceX;
UpixPosY = UpixPosY + AdvanceY;Now I have to figure out steering given this new approach
Previous
Trying to figure out ways to avoid obstacles with this new vector based approach
Next
Training workers
Advertisement
Advertisement
Advertisement
Discussion