Custom gravity for group of sprites

Hello again!
I am trying to make a group of falling sprites which are not affected by the overall gravity of the scene. However my implementation is not working, as when start the level, the sprites fall much faster than expected. Here’s my code:
game.js (where all the config attributes are)

var gameSettings = {
  playerXSpeed: 400,
  playerYSpeed: 1000
}

var config = {
  type: Phaser.AUTO,
  mode:Phaser.Scale.FIT,
  width: 1024,
  height: 640,
  backgroundColor: 0x000000,
  pixelArt: true,
  scene:[Boot, Title, Level1],
  physics: {
    default: 'arcade',
    arcade: {
        gravity: {y: 3000},
        debug: true
    },
    arcade: {
      gravity: {y: 3000},
      debug: true
  }
  },
};
var game = new Phaser.Game(config);

This is my level 1 code where the falling sprites are:

class Level1 extends Phaser.Scene {
constructor() {
	super("level1");
}
  grav = 40;
	create() {
    //background
    console.log('Loading bg...');
    this.lvl1Bg = this.add.image(0,0,"lvl1Bg").setOrigin(0,0);
    //floor platform
    this.stagePlatform = this.add.tileSprite(config.width/2, 640, 0, 0, 'stage').setOrigin(0.5, 0.8);
    this.physics.add.existing(this.stagePlatform, true);
    this.stagePlatform.enableBody = true;
    this.stagePlatform.body.immovable = true;      
    
   
//spawning tetrominos
this.tet1 = new Tetromino(this, 360, 50);
this.tet2 = new Tetromino(this, 360, 50);

this.tetrominos = this.physics.add.group();

this.tetrominos.getChildren().forEach(function (tetromino) {
  tetromino.body.setAllowGravity(false);
  tetromino.body.moves = true;
  tetromino.body.gravity.y = grav;
}, this);

this.tetrominos.add(this.tet1);

	update() {
    this.tetFall(this.tet1, 20);
  }
  
  
  //falling tetrominos
  tetFall(tetromino, accel) {
    tetromino.body.setAcceleration(0,accel);
    if (tetromino.y > config.height) {
      this.tetReset(tetromino);
    } else if (tetromino.y < 0){
      this.tetReset(tetromino);
    }
    if (tetromino.x > config.width) {
      this.tetReset(tetromino);
    } else if (tetromino.x < 0){
      this.tetReset(tetromino);
    }
  }
  tetReset(tetromino) {
    tetromino.y = 0;
    var randomX = Phaser.Math.Between(0, config.width);
    tetromino.x = randomX;
    tetromino.setFrame(Phaser.Math.Between(0, 59));
  }
  catchTetromino(serol,tetromino){
    // tetromino.disableBody(true, true);
    this.tetReset(tetromino);
  }
}
}


/*tetromino class*/
class Tetromino extends Phaser.Physics.Arcade.Sprite {
  constructor(scene, x=0, y=0, texture = 'tetromino', frame = Phaser.Math.Between(0, 60)) {
    super(scene,x,y,texture,frame)
    scene.add.existing(this)
    scene.events.on('update', this.update, this)
  }
}

I realised I had arcade gravity listed twice, but removing the redundant attribute didn’t seem to help…

You have the tertromino.body.setAllowGravity(false) set to false. Are the tetrominos supposed to be fallling? If so, you need to change your setAllowGravity method to true.

idk if mine is a good fix, but I ended up setting gravity in game settings to 0 and then setting it individually to the different sprite groups I had in the game :slight_smile:

My point was to have the tetrominos not be affected by overall gravity, which is why I set tertromino.body.setAllowGravity(false) and set a custom acceleration down, but the tetrominos were still being affected and fell way too fast.