Jump to content
  • 0

Jerky movement


Jumbofile

Question

Here is where im at currently

What is happening currently, is im trying to have a condition where the player would move 2 down and 1 over. Im not sure where the engine handles this or if the server is over-correcting for the movement but any insight would help. I can provide code examples if needed.

 

Here is some code

Client Player.cs

if (IsTileBlocked(X + 1, Y + 2, Z, CurrentMap, ref blockedBy) == -1)
                                    {
                                        tmpY += 2;
                                        tmpX++;
                                        IsMoving = true;
                                        Dir = 7;
                                        OffsetY = -(Options.TileHeight * 2);
                                        OffsetX = -Options.TileWidth;
                                        OffsetX = 0;
                                        FallDir = 7;
                                    }

 

Client entity.cs

case 6: //SW
                        if(Globals.Me.FallCount > 2)
                        {
                            OffsetY += deplacementTime;
                            OffsetY += deplacementTime;
                        }
                        else
                        {
                            OffsetY += deplacementTime;
                        }
                        
                        OffsetX -= deplacementTime;

                        if (OffsetY > 0)
                            OffsetY = 0;
                        if (OffsetX < 0)
                            OffsetX = 0;

                        break;

Please dont comment on code quality (unless there is a glaring issue), I want to get it working first and then ill clean up.

Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 1
1 hour ago, Jumbofile said:

How it works is every time the engine tries to update the position of the player/checks if they are grounded it adds one to the fall count. When i divide offsetY by 2 the player falls way too slow. Im not really sure what these offsets do tbh. Ill try to mess with offsetX because that could be the issue.

 

I think Offset are related to the fluidity of screen movement. To have a smooth fall you would probably need to play with these. So I suppose (like you did) if the player fall two tiles down and one tile right, OffsetY should be two times inferior (or superior) to OffsetX.

 

Maybe you could try tmpY += 1 and tmpX += 0.5? Like that for one deplacement the player will move just by one tile max and x value would be always at the right place.

Link to comment
Share on other sites

  • 1

Actually it's hard to figure out what FallCount is, but maybe you should try to divide the OffsetY by 2 when FallCount is greater than 2 instead of multiplying it by 2.

Moreoever, I don't know if it's related but actually the OffsetX value is always 0 in the code sample you have shared.

Link to comment
Share on other sites

  • 0

Put a dress of the fella and he's just floating down like Princess Peach. Perfect! I think you're doing great with the code btw! I'm no help but I'm 100% sure you will get it fixed! <3

Link to comment
Share on other sites

  • 0
4 hours ago, Shenmue said:

Actually it's hard to figure out what FallCount is, but maybe you should try to divide the OffsetY by 2 when FallCount is greater than 2 instead of multiplying it by 2.

Moreoever, I don't know if it's related but actually the OffsetX value is always 0 in the code sample you have shared.

How it works is every time the engine tries to update the position of the player/checks if they are grounded it adds one to the fall count. When i divide offsetY by 2 the player falls way too slow. Im not really sure what these offsets do tbh. Ill try to mess with offsetX because that could be the issue.

Link to comment
Share on other sites

×
×
  • Create New...