Jump to content

P2 collisions refuse to cooperate


Recommended Posts

I'm very new to Phaser (<1 week) but I've stared at the examples and I think it really looks as if I'm doing the right thing, yet collisions refuse to work.


In my gameState.create I run the following to set up my P2-physics:

     game.physics.startSystem(Phaser.Physics.P2JS);       game.physics.p2.setImpactEvents(true);      game.physics.p2.restitution = 0.8;      game.world.setBounds(-90, -300, 8200, 20000);      this.playerCG = game.physics.p2.createCollisionGroup();     this.enemiesCG = game.physics.p2.createCollisionGroup();     this.groundCG = game.physics.p2.createCollisionGroup();      game.physics.p2.updateBoundsCollisionGroup();

and later adding the player:

     this.player =         game.add.existing(             new Player(this, game, 750, 180, 0));     game.physics.p2.enable(this.player);     this.player.body.setCollisionGroup(this.playerCG);     this.player.body.collides(this.groundCG, this.player.collidesGround, this);     this.player.body.collides(this.enemiesCG);    

my grounds are the 'fistulaeHair' and are added:

         game.physics.p2.enable(fistulaHair);          fistulaHair.body.kinematic = true;          this.ground.add(fistulaHair);          fistulaHair.body.setCollisionGroup(this.groundCG); 

I'm expecting this.player.collidesGround to be called when flying into the ground but nothing happens:




It doesn't collide the the collidesGround has a console.log as first line which never fires.


I must be missing something very basic it feels like.


Also, as a side question, how do I test if I hit the world-end in P2-physics?


Any help much appreciated.

Link to comment
Share on other sites


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...