Jump to content

Programmatically set sprite position with isometric plugin


phantomburn
 Share

Recommended Posts

Hello,

 

I'm trying to make an isometric multiplayer game using the popular (and amazing) http://rotates.org/phaser/iso/ plugin.

 

The local player has their position updated similarly to this demo http://rotates.org/phaser/iso/examples/character.htm and then sends its sprite.isoPosition to the server. The server then sends this new position to all the other players. That's the basic idea so far.

 

My issue is that when I update these remote players' locations on the local client, they aren't smoothly updated (or even correctly updated). Currently I'm doing something like:

this.sprite.isoPosition.setTo(this.new.x, this.new.y, this.new.z);

And what happens is that instead of simply being placed in this new position, the sprite flies around the screen and then generally ends up somewhere out of bounds. I'm assuming this has something to do with the physics engine, which needs to be enabled on each player sprite so I can run collision checks.

 

Is there a way to keep the physics system enabled on these remote player sprites while also programmatically setting their position?

 

Thanks for any help.

Link to comment
Share on other sites

  • 4 months later...

Hey. You need to update this.sprite.isoPosition and also this.sprite.body.prev. This is because the velocity is calculated by the difference between the previous position and the position on sprite.body.preUpdate(). The reason it's flying around if because there is a large distance between the previous and new position, giving it a large velocity. Hope this helps.

 

Update: update isoPosition then call preUpdate() seems to work. Working example:

http://wassname.org/throw_blocks

 

Also moving sprites in preRender works, but isn't pretty.

 

@phantomburn What's your approach for server side physics? I got something similar working using headless phaser on the server side, but haven't stress tested it.

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...