wayfinder Posted June 14, 2014 Share Posted June 14, 2014 Hi all! I want to do stuff when my player hits my scenery, and when he stops contact. This is the code I use to listen:this.avatar.body.onBeginContact.add(this.playerBeginsContact, this);this.avatar.body.onEndContact.add(this.playerEndsContacts, this); I get the onBeginContact events just fine, but I receive practically no onEndContact events like this. Does anyone know why? As a test, I gave my scenery a listener for the onEndContact event, and what do you know, it gets an event every time – but also for collisions that have nothing to do with it! (like player vs the world bounds). Why is that?! Link to comment Share on other sites More sharing options...
wayfinder Posted June 14, 2014 Author Share Posted June 14, 2014 I'm doing some research on these events now and there definitely seems to be something wonky: The basic principle is that contact happens between this.update and this.render, and will be drawn after this.render and before the next this.update. Once contact has begun, shapes are assumed to be overlapping until a matching end contact event occurs. BUT! It seems that onEndContact delivers the wrong payload, here's an illustration: So it looks like it's firing off the first recorded onEndContact event for every following onEndContact. But I later managed to do this: I looked back at what happened before, and if you take a look at the first image, you will find that this contact pairing was exactly where shape 116 was when I started to jump: So I think it could be a case of the overlapKeeper returning the wrong index when asked which shapes are or aren't colliding, or maybe the storing is wonky already and fresh overlaps are only stored in the keeper when more overlaps end than it's currently thinking there are? Or that newly ended overlaps will only be added to the keeper if there are no overlaps at all? Something like that probably... Link to comment Share on other sites More sharing options...
wayfinder Posted June 14, 2014 Author Share Posted June 14, 2014 It's this issue, isn't it? https://github.com/schteppe/p2.js/issues/90 Damn.. fixed in p2 already I hope this isn't something that will break Phaser when I update it in there george 1 Link to comment Share on other sites More sharing options...
wayfinder Posted June 14, 2014 Author Share Posted June 14, 2014 Well that's a couple of hours well spent on learning to use github before I go on a bug hunt. But there are still some kinks, like only the scenery onEndContact listener returning any onEndContacts.. Link to comment Share on other sites More sharing options...
valueerror Posted June 15, 2014 Share Posted June 15, 2014 oh.. i ran into this a while ago.. and thx to george i found the github issue before i spent hours.. but this isn't fixed in phaser or is it? you'll have to update p2 on your own and then recompile and cross fingers right? Link to comment Share on other sites More sharing options...
wayfinder Posted June 15, 2014 Author Share Posted June 15, 2014 I just updated the relevant lines from the commit in phaser.js and it seems to work! but i haven't had time yet to thoroughly test. Link to comment Share on other sites More sharing options...
wayfinder Posted July 4, 2014 Author Share Posted July 4, 2014 There is an additional P2 bug playing into the issue, described here: https://github.com/photonstorm/phaser/issues/969 Link to comment Share on other sites More sharing options...
presidenten Posted October 10, 2014 Share Posted October 10, 2014 I just updated the relevant lines from the commit in phaser.js and it seems to work! but i haven't had time yet to thoroughly test. So did it work in the end? And if so, which lines do I have to update to make it work here on my computer? :-) Link to comment Share on other sites More sharing options...
Recommended Posts