Jump to content

Disable collisions in p2 for only one Body


goyeneche
 Share

Recommended Posts

I am making a spaceship game, to be more optimized I want to avoid calculing collisions when are far away from the player.

 

I tried doing:

 

1)

enemy.body.enable = false;

2) Also this doesn't work. Because I never set it to true:

enemy.body.data.shapes[0].sensor = false;

3) Kill and revive them: it's not the best solution, because I want them to change positions.

 

Nothing seems to work. What can I do?

This is a part of my code for collisions in p2:

this.body.setCollisionGroup(enemyCollisionGroup);this.body.collides([bulletCollisionGroup, playerCollisionGroup, enemyCollisionGroup, asteroidCollisionGroup], null );this.body.onBeginContact.add( this.startConstantDamage, this );this.body.onEndContact.add( this.endConstantDamage, this );

Thanks

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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