Jump to content

Phaser P2 Kinematic Collisions


mafiaflysoft
 Share

Recommended Posts

Hi All

I have spend all night trying to figure this out. I changed my game from Arcade to P2 physics and can not for the life of me get collisions to work. I changed my body types to Kinematic since I don't need any physics applied to my object. Below is my code :

 

createEnemies: function() {

         var enemy = enemies.getFirstExists(false);
        if (enemy) {
               
                enemy.reset(500, this.game.world.height);
                enemy.body.fixedRotation=true; 
                enemy.body.kinematic = true;
                enemy.body.velocity.y = -100;
				enemy.anchor.setTo(0.5, 0.5);
				enemy.body.moves = true;
                enemy.body.debug = true;
                enemy.body.data.shapes[0].sensor = true;
                enemy.scale.set(scaleRate);
                enemy.body.onBeginContact.add(blockHit, this); // DOES NOT TRIGGER
                //enemy.body.collides(bulletsCollisionGroup, hitEnemy, this); // DOES NOT TRIGGER

        }

 

If I change my body from Kinematic = true, to Kinematic = false, then all the events trigger. Any ideas?

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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