Jump to content

Best way to interpolate between 2 positions?


thebest108

Recommended Posts

This has been bothering me too much. No matter what I do, I can't seem to fix the stutter caused by receiving new positions. So currently Im sending a packet every tick with the ship's position and velocity and orientation. Im also storing the values of the previous packet received. Even though angular momentum interpolates perfectly, using the same method for translation has "mixed results". Judge for yourself

 

[embed=425,349]<iframe width="560" height="315" src="https://www.youtube.com/embed/dpW0NITzrHw" frameborder="0" allowfullscreen></iframe>[/embed]

 

As you can see the translation is constantly stuttering. Im getting the values using this

 

moddedX = ship.posX+((ship.interpController.latestVelocity.X)*partialTicks);

moddedY = ship.posY+(ship.interpController.latestVelocity.Y)*partialTicks;

moddedZ = ship.posZ+(ship.interpController.latestVelocity.Z)*partialTicks;

 

Does anyone know a simple interpolation method? I really want to get this released soon

 

Edit: I can't simulate any of the physics on client side and then correct because it's a dynamically changing rigid body, meaning its mathematically impossible to get anything relevant from running it on client. Im just running on velocity here

"you seem to be THE best modder I've seen imo."

~spynathan

 

ლ(́◉◞౪◟◉‵ლ

Link to comment
Share on other sites

Now, I am no genius, but even if you update it every tick would that not be fast enough? I mean, there are 20 ticks per second I think, right? That means that your ship would be suck updating at the equivalent of 20 fps...? Now if you change your Minecraft max fps to be 20, you will notice how terrible that is, so It is no doubt that it looks choppy when being updated.

 

Keep in mind, I am a complete newb here, and I know not a lot about Forge etc, so I am sure there is some way around that.

.|\| E0 |\|.      /\ Fr0

Link to comment
Share on other sites

Actually, I am not sure if my last comment applies here, because I think you are handling it differently than how I had thought. So maybe just ignore that last suggestion. I had thought you were updating the position every tick rather than just sending the packets. Sorry xD

.|\| E0 |\|.      /\ Fr0

Link to comment
Share on other sites

Like diezieben07 said, interpolate between old and new variables.

 

The way it is usually done in Minecraft is, for example, with rotation:

float renderYaw = entity.prevRotationYaw + (entity.rotationYaw - entity.prevRotationYaw)*partialTicks;

 

So you use the same formula for position, scale, rotation, all that.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.