Skip to content

Instantly share code, notes, and snippets.

@damian-pastorini
Last active December 6, 2020 14:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save damian-pastorini/d3175827233883f77ef33c585842debf to your computer and use it in GitHub Desktop.
Save damian-pastorini/d3175827233883f77ef33c585842debf to your computer and use it in GitHub Desktop.
this.p2world.on('impact', function(evt){
var bodyA = evt.bodyA,
bodyB = evt.bodyB;
if(bodyA.hasOwnProperty('playerId')){
console.log('bodyA is the player! ', bodyA.playerId);
var currentPlayer = this.state.players[client.sessionId];
bodyA.velocity = [0,0];
} else {
if(bodyB.hasOwnProperty('playerId')){
console.log('bodyB is the player! ', bodyB.playerId);
var currentPlayer = this.state.players[client.sessionId];
bodyB.velocity = [0,0];
} else {
console.log('who the fuck is moving???');
}
}
console.log('bodies position: ', bodyA.position, bodyB.position);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment