I have my units that i move around my map with path finding. The units can move in 8 directions, currently i have the units moving around the map with a extremely basic check against the unit's current position vs. the next target destination in an array of Vector2s (the path). However, the movement is rather jagged and not very fluid.
Current code (I know its not very good, i did this just to test out the pathfinding really);
if (Position.X < Path [CurrentPathPoint].X) {
SpeedDir.X = 1;
}
if (Position.X > Path [CurrentPathPoint].X) {
SpeedDir.X = -1;
}
if (Position.Y < Path [CurrentPathPoint].Y) {
SpeedDir.Y = 1;
}
if (Position.Y > Path [CurrentPathPoint].Y) {
SpeedDir.Y = -1;
}
Position += SpeedDir * Speed;
I should mention that im not looking for any sort of rotational movement, just smooth diagonal and directional movement. However, i'm at a lose on how i can achieve that... So any help greatly appreciated :)!
Edit: Smooth Transitioning between movements is what i'm looking for. Right now, the units sometimes (not sure how to describe but they "stutter" along), looks like they are shaking when moving. As to what i tried before, i had the position being updated directly in the If statements, that didn't give me any stuttering but did not seem like a good approach so i changed to the one above.
Vector2.CatmullRom
\$\endgroup\$