Solace777 Posted November 24, 2021 Share Posted November 24, 2021 var deltaX = ship.x - object_sprite.position.x; var deltaY = ship.y - object_sprite.position.y; var radians = Math.atan2(deltaY, deltaX); // In radians // Set postion exactly to server object_sprite.position.x += deltaX * delta; object_sprite.position.y += deltaY * delta; object_sprite.rotation.z = ship.direction_rad; Hi all, I'm trying to create an animation for a spaceship. This is the code above. ship.x and ship.y are updated from the server every 1 second. I want to move the object_sprite to the new position. It totally works but it "eases". I need it to animate evenly. I am not using TweenJS. Any thoughts? Quote Link to comment Share on other sites More sharing options...
b10b Posted November 24, 2021 Share Posted November 24, 2021 Probably not a Pixi question. What's "delta"? If it was 0.5 then the ship will split the difference between previous position and server position "evenly". That's not to say it will appear smooth between subsequent updates though as their frequency is not guaranteed to be consistent. Genuinely smooth and even interpolation (over network) requires much more consideration (e.g. prediction, reversing time). It depends on your game and audience whether the benefit is worth the hassle. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.