Ulbast Posted April 10, 2017 Share Posted April 10, 2017 Hi all, I have a problem with collision. All my game is based on these codes: game.physics.arcade.collide(bullets, chest2,collision_handler); And it works. But... how to code collision two identical bullets? When I write like this: game.physics.arcade.collide(ebullets, ebullets, collision_handler); Only one of them is dying. How to do it? function collision_handler (object1, object2) { object1.kill(); object2.kill(); } Link to comment Share on other sites More sharing options...
samid737 Posted April 11, 2017 Share Posted April 11, 2017 Hi here is an example of how you can let bullets collide with each other and get killed by using the Phaser.Weapon plugin: Notice that if your fire two bullets exactly horizontally, they will collide and both get killed. You could probably extend it to other players(your enemy) as well, since the collision check is done for the entire weapon.bullets group. Hope this helps! Link to comment Share on other sites More sharing options...
Ulbast Posted April 12, 2017 Author Share Posted April 12, 2017 Well.. we have the same functions, but mine is not working ;/ Link to comment Share on other sites More sharing options...
samid737 Posted April 12, 2017 Share Posted April 12, 2017 In the example I am using the latest version. Are you using the latest version of Phaser? Link to comment Share on other sites More sharing options...
Ulbast Posted April 12, 2017 Author Share Posted April 12, 2017 I just realised that I'm one update behind. I will update, then. Link to comment Share on other sites More sharing options...
Ulbast Posted April 13, 2017 Author Share Posted April 13, 2017 After update, nothing changed. The function is not working ;/ Link to comment Share on other sites More sharing options...
samid737 Posted April 13, 2017 Share Posted April 13, 2017 In your bullet collide function you use ebullets against ebullets collision check. In the first one you are checking bullets against chest2. Is ebullets a group? You need to check a group vs group, so bullets,bullets. otherwise you make sure that you are checking collision for different objects(ebullets vs ebullets will fail if there is only one object with that name). So: group vs group or sprite vs group or sprite vs sprite game.physics.arcade.collide(bullets, bullets, collision_handler); http://phaser.io/docs/2.6.2/Phaser.Physics.Arcade.html#collide Link to comment Share on other sites More sharing options...
Recommended Posts