Jump to content
  • Advertisement
Sign in to follow this  
MustSeeMelons

Isometric character movement, traversing nodes

This topic is 2107 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi.

I have a question regarding character movement in an isometric turn based strategy game, characters move from tile to tile only. As of now, I'm using linear interpolation to move the character from tile to tile, but that causes a problem: the character lags when switching movement.

Did some research, and found out, that I should be using "Piecewise linear interpolation" - how does it work in the real world? I found articles about it, but they weren't so easy to understand, mostly because they are very mathematical and English is not my native tongue. Could someone please describe it more understandably?

For now, I'm using the following code to traverse between two nodes:

void Character::MovementUpdate(){
    if(!moving){
        movesLeft=moveTime;
    }
    else{
        float rate=(float)(moveTime-movesLeft)/moveTime;
        posX=(int) ( (float)(currentTile->x+20)*rate + (float)posX*((float)1-rate));
        posY=(int) ( (float)(currentTile->y-25)*rate + (float)posY*((float)1-rate));
        movesLeft--;

        if(movesLeft==0){
            if(moveList.size()>0){
                Move(moveList.at(0));
                moveList.erase(moveList.begin());
            }else{
                moving=false;
                characterSprite->UpdateAnimateSprite(moving);
            }
            movesLeft=moveTime;
        }
    }
}

If the character is moving, calculate it's coordinates. There are 30 steps for the character to move from A to B, and if there are more nodes to go to, go to the next node. For path-finding A* is being used, which returns a list of moves the character has to make, for example: North, North, West; etc.

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!