Jump to content

Animation Trouble


Solace777
 Share

Recommended Posts

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?

Link to comment
Share on other sites

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.

 

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
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...