Hi!
I have been around for a little while and I think I never mentioned that I am a game coder coming from ActionScript and Vanilla. After a long time rusting the joints I am back to the game (no pun intended). I am starting with Phaser 3 and am doing some tests myself of how to do basic things before to jump over a project that an old client ordered to me.
Anyway, this morning I was playing with collision tests when suddenly I bumped (no pun intended again!) to this funny behavior. I really would like to know if this a bug or purposeful. I realized that in a particular situation if you try to detect the collision between an object moving towards a stopped one, when they collide the moving object will push the stopped object. The funniest part is that it only will happen if both objects has their hit areas set to circle. Better explaining, if you leave it as default (square) it won’t happen. In fact if at least one of the two objects has its area as square it won’t happen. That’s why it has the appearance of a bug to me.
Also being experienced with several other languages it really sounds odd to me that an event function that supposedly should only make a test causes a behavior change. From my perspective a test should produce only a true/false result but in any circumstance change things (it should be left to the coder to decide what to do depending on the result).
Here it goes the code to reproduce the behavior:
var Moving;
var Stopped;
class Foo extends Phaser.Scene
{
constructor ()
{
super();
}
create ()
{
Stopped = this.physics.add.sprite(800, 300,"");
Stopped.setCircle(18);
Moving = this.physics.add.sprite(500, 300, "");
Moving.setCircle(18)
this.physics.add.collider(Moving, Stopped, function (Moving, Stopped) {
});
}
update () {
Moving.x += 5;
}
}
const config = {
type: Phaser.AUTO,
parent: "Foo",
width: 1024,
height: 768,
pixelArt: true,
backgroundColor: 0xffffff,
physics: {
default: "arcade",
arcade: {
debug: true
}
},
scene: [ Foo ]
};
const game = new Phaser.Game(config);