Jump to content

Problem with "getTileAtWorldXY"?


Recommended Posts

Hey there,

just upfront: I'm quite new to phaser and I'm not 100% sure I did not do somethign wrong, but at this point I just would expect a diffrent result than what I get

I added attachments that show what my Issue is.

This example is running over a server to transmit the coordinates, I just use the tilex/tiley coordinates (not in pixels but in the tilemap grid) to dertermin where the curretn sprite wants to move

I use easystar for pathfinding

in the screens the left side is the "watching" person and the right side is the "causing" person

the first screenshot shows the "start positions", in the second screenshot I clicked the tile on wich you see the sprite now, and it moved there on both clients (left aswell as right) but when I try to use the coordinates of the sprite to get the current tile of the layer the sprite is on, it does not work. On the right side (the watcher), it selects a totally wrong tile (marked in a red circle, but keep in mind the actualy tile is not visible as it is under the layer), on the left side however you see it selected the right tile as start element as expected

On the right side the "sand layer" has a scrollfactor, a scale and changed depth

The end position is correct because I use the tilex/tiley coordinates directly (instead of pixels), but using this function

let characterTile = activeLayer.tilemapLayer.getTileAtWorldXY(this._sprite.x, this._sprite.y)

the same coordinates do not return the tile the sprite is actually on

when I use tilex/tiley for everything it works fine (but it is not easy to make good use of it in that specific situation)


I hope it is kinda clear what I mean, if not I will do my best to explain better



Link to comment
Share on other sites


  • Recently Browsing   0 members

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