Has anybody got the code for smooth move i can copy please. I've been adding a lot of things with AI without issue but it's having a hard time implementing smooth move correctly.
This is the code it added to playerobject which basically made it like a slideshow.
Thanks
This is the code it added to playerobject which basically made it like a slideshow.
Code:
else
{
// Hybrid smooth movement: frame-based with time interpolation
int count = Frame.Count;
int index = FrameIndex;
if (Frame.Reverse) index = count - FrameIndex - 1;
// Calculate base progress from frame index
double baseProgress = (double)(index + 1) / count;
// Add sub-frame interpolation for smoothness
double frameProgress = 0;
if (FrameInterval > 0)
{
double timeSinceLastFrame = CMain.Time - (NextMotion - FrameInterval);
frameProgress = Math.Max(0, Math.Min(timeSinceLastFrame / FrameInterval, 1.0));
}
// Combine frame progress with sub-frame interpolation
double progress = Math.Min((baseProgress - (1.0 / count)) + (frameProgress / count), 1.0);
switch (Direction)
{
case MirDirection.Up:
OffSetMove = new Point(0, (int)((MapControl.CellHeight * i) * (1.0 - progress)));
break;
case MirDirection.UpRight:
OffSetMove = new Point((int)((-MapControl.CellWidth * i) * (1.0 - progress)), (int)((MapControl.CellHeight * i) * (1.0 - progress)));
break;
case MirDirection.Right:
OffSetMove = new Point((int)((-MapControl.CellWidth * i) * (1.0 - progress)), 0);
break;
case MirDirection.DownRight:
OffSetMove = new Point((int)((-MapControl.CellWidth * i) * (1.0 - progress)), (int)((-MapControl.CellHeight * i) * (1.0 - progress)));
break;
case MirDirection.Down:
OffSetMove = new Point(0, (int)((-MapControl.CellHeight * i) * (1.0 - progress)));
break;
case MirDirection.DownLeft:
OffSetMove = new Point((int)((MapControl.CellWidth * i) * (1.0 - progress)), (int)((-MapControl.CellHeight * i) * (1.0 - progress)));
break;
case MirDirection.Left:
OffSetMove = new Point((int)((MapControl.CellWidth * i) * (1.0 - progress)), 0);
break;
case MirDirection.UpLeft:
OffSetMove = new Point((int)((MapControl.CellWidth * i) * (1.0 - progress)), (int)((MapControl.CellHeight * i) * (1.0 - progress)));
break;
}
}
Thanks
