Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Arcade Physics: Immovable Object Moves when it has circular collision #7054

Open
hunkydoryrepair opened this issue Feb 21, 2025 · 2 comments

Comments

@hunkydoryrepair
Copy link

hunkydoryrepair commented Feb 21, 2025

Version

  • Phaser Version: 3.88.0 - 3.88.2
  • Operating system: Mac OS and Windows
  • Browser: Chrome/all

Description

An immovable object with circular collision will move when an object with rectangular collision collides with it.
This is inconsistent with all earlier versions, and with rectangular objects.
In order to prevent an object from moving in 3.88.1, the body must be set to immovable, and have pushable explicitly set to false AND the object colliding with it must be pushable.

Example Test Code

in comments. the behavior is clear in the separateCircle function of world.js. When object is immovable but pushable, it moves it.

Additional Information

The behavior is USEFUL, but an unnecessary breaking change, and inconsistent with other shapes. setImmovable could set pushable to false, and require it be explicitly enabled, which should prevent it from being a breaking change.

@hunkydoryrepair
Copy link
Author

https://jsfiddle.net/eb9ygph5/

const GameScene = new Phaser.Scene();

GameScene.init = function() {};

GameScene.preload = function() {};

GameScene.create = function() {
  const img = this.physics.add.sprite(150, 150, "newmachine");
  img.body.setCircle(50, 0, 0);
  img.body.setImmovable();
  const img2 = this.physics.add.sprite(450, 150, "newmachine");
  img2.body.setSize(50, 50);
  this.physics.add.collider(img2, img);
  img2.body.setVelocity(-20, 0);
  
  // END Collision Detector definitions
};

// UPDATE
GameScene.update = function() {};

const config = {
  type: Phaser.AUTO,
  width: 640,
  height: 480,
  physics: {
    default: 'arcade',
    arcade: {
      debug: true,
    }
  },
  scene: [GameScene]
};

const game = new Phaser.Game(config);

@hunkydoryrepair
Copy link
Author

hunkydoryrepair commented Feb 21, 2025

This fiddle shows the behavior did not happen as recently as 3.87.0
https://jsfiddle.net/eb9ygph5/2/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant