Hi,
I tried the attractor in this example and got it working in my space game, but i wanted more realistic gravity and read about Neomak’s succesfull attempt.
Is this the proper way to get it done?
I have tried setting my game physics config to:
physics: { default: 'matter', matter: { plugins: { attractors: true }, debug: true } }
And then created a planet class:
export default class Planet extends Phaser.Physics.Matter.Image {
constructor(scene, x, y) {
super(scene.matter.world, x, y, ‘planet’, null, {
shape: {
type: ‘circle’,
radius: 150
},
plugin: {
attractors: [Phaser.Physics.Matter.Matter.Plugin.resolve(“matter-attractors”).Attractors.gravity]
}
});this.setStatic(true); this.setFriction(1) scene.add.existing(this); }
}
I’m not sure I’m doing this right. I get strange behavior with weird warping gravity that ends up being some kind of anti-gravity. I tried changing all objects masses but without any luck either.
Would really like to get this working since it’s a very nice feature!