PhaserEditor2D / PhaserEditor2D-v3

A web-based IDE for HTML5 game development. Powered by Phaser.
https://phasereditor2d.com
MIT License
426 stars 57 forks source link

Can not set the offset of Arcade Physics Body Geometry #280

Closed k206i closed 1 year ago

k206i commented 1 year ago

Version

Description

Offset of Arcade Physics Body Geometry not working. I have seted some offset: image

But body has collide like offset was not set: image

PhaserEditor2D commented 1 year ago

Please can you enable the physics debug? In that way we can know what's going on. In the game config, set:

const game = new Phaser.Game({      
  physics: {
    default: "arcade",
    arcade: {
        debug: true
    }
  }
});
PhaserEditor2D commented 1 year ago

BTW, is it scaled the platform object?

k206i commented 1 year ago

Please can you enable the physics debug? In that way we can know what's going on. In the game config, set: image

BTW, is it scaled the platform object?

Yes, this is a scaled platform prephab image

PhaserEditor2D commented 1 year ago

Please, try without scaling the platform. Or you have to call the platform.body.updateFromGameObject() method after you scale the platform.

https://newdocs.phaser.io/docs/3.60.0/focus/Phaser.Physics.Arcade.StaticBody-updateFromGameObject

PhaserEditor2D commented 1 year ago

BTW, I recommend you take a look at this tutorial. In this part it talks about refreshing the body after changing the scale: https://youtu.be/nMXOcrQU9cs?list=PLB8gI_5U0MvBiK7GExn8ONPk5jDPd2KlE&t=237

k206i commented 1 year ago

Please, try without scaling the platform. Or you have to call the platform.body.updateFromGameObject() method after you scale the platform.

It works for me. Thank you!

k206i commented 1 year ago

BTW, I recommend you take a look at this tutorial. In this part it talks about refreshing the body after changing the scale:

Thanks for your tutorials! They help a lot!