On Friday, my project was working fine. Upon resuming work on it this morning, I quickly found my scenes were no longer being destroyed correctly. Code such as this was causing an error:
this.on('destroy', this.onDestroy);
this.entity.collision.on('collisionstart', this.onContactStart, this);
GameObject.prototype.onDestroy = function()
{
this.off('destroy', this.onDestroy);
this.entity.collision.off('collisionstart', this.onContactStart, this);
}
The error: “Uncaught TypeError: Cannot read property ‘off’ of undefined”
In the onDestroy function, this.entity no longer has a collision object from which to remove the event. As I say, this was working fine until this morning, and many scripts in my project rely on it.
At the end of every day, I export my project and save it into SVN. Out of curiosity, I exported a new version with this problem in it and just swapped out the playcanvas-stable.min.js file with the one from Friday’s export, and it worked fine. So something changed in the meantime has caused this issue. The files are indeed 1kb different.
I’ve made a sample project here: https://playcanvas.com/project/578084/overview/bugtest
Any advice would be greatly appreciated, thank you.