I am currently working on the diagonal movement feature and I am stuck on the fluidity of the animation.
Basically, I've added more directions to the "HandleInput" and "ProcessDirectionalInput" methods  in "Intersect.Client.Entities.Player", but I am totally lost about how to make the animation smoother on diagonal movements.
Â
I think it has something to do with the OffsetX and OffsetY field, but I don't know how it works.
Â
Can someone help me with this?
Â
Spoiler
Â
// HandleInput()
// {..}
var move = movex / 10 + movey;
Globals.Me.MoveDir = -1;
if (movex != 0f || movey != 0f)
{
if (movex > 0)
{
Globals.Me.MoveDir = 3;
}
switch (move)
{
case 1.0f:
Globals.Me.MoveDir = 0; // Up
break;
case -1.0f:
Globals.Me.MoveDir = 1; // Down
break;
case -0.1f: // x = 0, y = -1
Globals.Me.MoveDir = 2; // Left
break;
case 0.1f:
Globals.Me.MoveDir = 3; // Right
break;
case 0.9f:
Globals.Me.MoveDir = 4; // NW
break;
case 1.1f:
Globals.Me.MoveDir = 5; // NE
break;
case -1.1f:
Globals.Me.MoveDir = 6; // SW
break;
case -0.9f:
Globals.Me.MoveDir = 7; // SE
break;
}
}
// ProcessDirectionalInput()
// {..}
switch (MoveDir)
{
// Dir is the direction the player faces
// tmp is the next position of the player
// Offset is the position the animation start ? I don't know...
// {...}
case 4: // NW
tmpX--;
tmpY--;
Dir = 2;
IsMoving = true;
OffsetY = -Options.TileHeight;
OffsetX = Options.TileWidth;
break;
case 5: // NE
tmpX++;
tmpY--;
Dir = 3;
IsMoving = true;
OffsetY = -Options.TileHeight;
OffsetX = -Options.TileWidth;
break;
case 6: // SW
tmpY++;
tmpX--;
Dir = 2;
IsMoving = true;
OffsetY = -Options.TileHeight;
OffsetX = Options.TileWidth;
break;
case 7: // SE
tmpY++;
tmpX++;
Dir = 3;
IsMoving = true;
OffsetY = -Options.TileHeight;
OffsetX = -Options.TileWidth;
break;
}
Question
Shenmue
I am currently working on the diagonal movement feature and I am stuck on the fluidity of the animation.
Basically, I've added more directions to the "HandleInput" and "ProcessDirectionalInput" methods  in "Intersect.Client.Entities.Player", but I am totally lost about how to make the animation smoother on diagonal movements.
Â
I think it has something to do with the OffsetX and OffsetY field, but I don't know how it works.
Â
Can someone help me with this?
Â
Â
Â
Â
Â
Â
Link to comment
Share on other sites
4 answers to this question
Recommended Posts