Code: Select all
if (units[t].loc.X<(units[t].tloc.X-(elapsed*units[t].spd*uspdmod))) {units[t].loc.X +=(elapsed*units[t].spd*uspdmod);}
else if(units[t].loc.X<units[t].tloc.X) {units[t].loc.X +=(units[t].tloc.X-units[t].loc.X);}
if (units[t].loc.X>(units[t].tloc.X+(elapsed*units[t].spd*uspdmod))) {units[t].loc.X -=(elapsed*units[t].spd*uspdmod);}
else if(units[t].loc.X>units[t].tloc.X) {units[t].loc.X -=(units[t].tloc.X-units[t].loc.X);}
if (units[t].loc.Y<(units[t].tloc.Y-(elapsed*units[t].spd*uspdmod))) {units[t].loc.Y +=(elapsed*units[t].spd*uspdmod);}
else if(units[t].loc.Y<units[t].tloc.Y) {units[t].loc.Y +=(units[t].tloc.Y-units[t].loc.Y);}
if (units[t].loc.Y>(units[t].tloc.Y+(elapsed*units[t].spd*uspdmod))) {units[t].loc.Y -=(elapsed*units[t].spd*uspdmod);}
else if(units[t].loc.Y>units[t].tloc.Y) {units[t].loc.Y -=(units[t].tloc.Y-units[t].loc.Y);}
I thought this would prevent jittering, but I still get it at some positions, but not others.
I guess what I'm asking is, what would be the best way to stop units from jumping around their target location?
Thanks for your time.