toto88x Posted January 16, 2014 Share Posted January 16, 2014 Hi, In my game I have cars. When car run into each other with velocity, I want them to stop moving. So I did this in my code:create: function () { cars = game.add.group(); cars.setAll('body.immovable', true);}update: function() { game.physics.collide(cars, enemy); // works perfectly game.physics.collide(cars, cars); // do nothing }But with this code cars just go through each-other, they never collide and stop. So how can I make a group collide with himself? Thanks! Link to comment Share on other sites More sharing options...
piotr409 Posted January 16, 2014 Share Posted January 16, 2014 Propably it is because of cars.setAll('body.immovable', true); Try add to each car : car.body.customSeparateX = true; car.body.customSeparateY = true;I had similar problem, when two immovable objects were unable to handle collision with each other. Link to comment Share on other sites More sharing options...
toto88x Posted January 16, 2014 Author Share Posted January 16, 2014 Propably it is because of cars.setAll('body.immovable', true); Try add to each car : car.body.customSeparateX = true; car.body.customSeparateY = true; Thanks, I just tried with my code and adding: cars.setAll('body.customSeparateX', true);cars.setAll('body.customSeparateY', true);And I still have the same issue. Link to comment Share on other sites More sharing options...
rich Posted January 17, 2014 Share Posted January 17, 2014 Two immovable sprites can never collide with each other, because they're, well.. immovable! If what you require is a sprite that's immovable against only certain other sprites, which can't be done 'natively' right now and has to be handled in custom code. I'm not sure that the same group can collide with itself in 1.1.3, but we definitely fixed that in 1.1.4 (still in dev though) - even so you'd still need to handle this situation with custom code because even that won't get over the issue of 2 immovable objects needing to collide. sebamawa 1 Link to comment Share on other sites More sharing options...
toto88x Posted January 17, 2014 Author Share Posted January 17, 2014 Two immovable sprites can never collide with each other, because they're, well.. immovable! If what you require is a sprite that's immovable against only certain other sprites, which can't be done 'natively' right now and has to be handled in custom code. I'm not sure that the same group can collide with itself in 1.1.3, but we definitely fixed that in 1.1.4 (still in dev though) - even so you'd still need to handle this situation with custom code because even that won't get over the issue of 2 immovable objects needing to collide. Well, that make sense! :-) What I want to do: when a car collide another car, I want the 2 cars to simply stop moving.So how can I do this in 1.1.3? Should I use game.physics.overlap(cars, cars, car_collide, null, this)? Can a group overlap with himself? If not, how to do this? Thanks! Link to comment Share on other sites More sharing options...
Recommended Posts