Search the Community
Showing results for tags 'lerp'.
-
I've followed many guides on the internet and I have found success in none of them so far. My situation is having a game where updates from the server are inconsistent, so-far I have found no lerp that can handle this without jumping and jittering a bunch.
-
Im trying to make a lerp function on an online game. Im doing this by having a buffer list, I append each server update to a list, and lerp over the contents, here is an example: movementBuffer.unshift(gameUpdate); //when a new update is received //in the main loop timeElapsed += delta; lerpPerc = timeElapsed / updateRate; //percent which is lerped to if(lerpPerc > 1){ //when the lerp is finished, the states that were just lerped are removed from the buffer movementBuffer.splice(prevData.length - 2, 2); //remove the previous states from the buffer state1 = prevData[prevData.length - 1]; state2 = prevData[prevData.length - 2]; timeElapsed = 0; lerpPerc = 0; } for (i = 0; i < state2["players"].length; i++) { // update the players prevY = state1["playery" + state["players"][i]]; prevX = state1["playerx" + state["players"][i]]; x = state2["playerx" + state["players"][i]]; y = state2["playery" + state["players"][i]]; //lerp to the new x and y playerCoords[recivedData["players"][i]][0] = lerpF(prevX, x, lerpPerc); playerCoords[recivedData["players"][i]][1] = lerpF(prevY, y, lerpPerc); } The problem here is the `lerpPerc` goes by too quickly, so it basically deletes all items in the buffer, leaving nothing to be lerped to. What am I doing wrong here?
- 4 replies
-
- lerp
- multiplayer
-
(and 1 more)
Tagged with:
-
Hi there ! I got some blurry simple sprite movement when moving and having a camera lerp. It's only when I use more than 60FPS ( 144 exactly ) ( set up with this.game.time.desiredFps = 144; ) So i tried to block at 60 FPS with this.game.time.desiredFps = 144; but I got some ghosting like effect. It's really easy to see it on this example : http://phaser.io/examples/v2/p2-physics/kill-and-revive Anyone got an idea to avoid the blur or the ghosting ? That would help me so much
-
I'm using babylon 2.4 here. I've providing position vectors to the Vector3.lerp function. The result seems to be a string concatenation instead of arithmetic addition. Below I'm just showing x, z coordinates because y is always constant from: 2.000, 0.000 to: 2.400, 0.000 lerp percentage: 0.33589999999996506 lerped position: 2.0000.134359999999986, 0.0000 lerp percentage: 0.9552999999999884 lerped position: 2.0000.38211999999999524, 0.0000 so this is going from (2.0, 0.0) to (2.4, 0.0) The 1st resulting lerp should be 2.134359999999986 but instead its 2.0000.134359999999986
-
Hi there, by default it seems the ANIMATIONTYPE_QUATERNION slerps between 2 quaternions the short way (270 degrees turns into -90 for instance). If I compute the angle between the 2 quaterinon and determine that it's more than 180, how would I go about slerping it the long way? I tried looking at the code but variable names such as num1 num2 num3 num4 num5 num6 didn't really help Any help appreciated! Cheers, Quaternion.Slerp = function (left, right, amount) { var num2; var num3; var num = amount; var num4 = (((left.x * right.x) + (left.y * right.y)) + (left.z * right.z)) + (left.w * right.w); var flag = false; if (num4 < 0) { flag = true; num4 = -num4; } if (num4 > 0.999999) { num3 = 1 - num; num2 = flag ? -num : num; } else { var num5 = Math.acos(num4); var num6 = (1.0 / Math.sin(num5)); num3 = (Math.sin((1.0 - num) * num5)) * num6; num2 = flag ? ((-Math.sin(num * num5)) * num6) : ((Math.sin(num * num5)) * num6); } return new Quaternion((num3 * left.x) + (num2 * right.x), (num3 * left.y) + (num2 * right.y), (num3 * left.z) + (num2 * right.z), (num3 * left.w) + (num2 * right.w)); };