I’m currently working on movement. I want to be able to click on a tile and have the player move to it. I thought I’d try to read the position of the tile itself, after a mouse press on a tile.
I also have the camera following the camera, and set to zoom. Adds a layer to the already difficult task I’ve put ahead of me. I believe it may have something to do with the scroll factor. I’m not sure.
Any suggestions or help would be much appreciated.
this.input.on("pointerdown", (pointer)=> {
let d = map.getTileAtWorldXY(pointer.worldX, pointer.worldY, this.cameras, layer1)
console.log(d)
})
I’m trying to get the tile after clicking on it so I can read the world position. It returns null in most of my attempts. I also placed in the boolean for nonNull but that didn’t work either. I’m having another go at this.
Oh I got that part working.
this.input.on("pointerdown", (pointer)=> {
let d = map.getTileAtWorldXY(pointer.worldX, pointer.worldY, true)
})
I’ve written it out in a state machine: I’m giving the pixelX and Y to the moveTo function.