Scene Changing Script

The scene changing isn’t working with the collision I set up, could someone help?

Project: PlayCanvas 3D HTML5 Game Engine

Hi @Overbaked! Please give a little more information about where to look. For example which scene, script and entities. Thank you.

1 Like

Hi @Overbaked,

I took a look at your project, and found a few issues:

In changeScene.js, line 17:

this.entity.collision.on('collisionstart', this.onCollisionStart, this);

should become:

this.entity.collision.on('triggerenter', this.onCollisionStart, this);

Here is the relevant documentation for this change: Trigger Volumes | Learn PlayCanvas

Fixing this led to an undefined error on line 27:

if (entity.other.name == this.player.name) {

should become:

if (entity.name == this.player.name) {

as entity.other is not something passed by the event. I’m not sure if this code was copied from elsewhere. I know it can be hard to catch everything when using unknown code.

You are also getting a collision error because the box you have below your bouncing platform has bouncing.js attached, but does not have a CollisionComponent attached to it.

Here is a fork of your project with the corrections from above. As soon as your are comfortable with it, I will delete it as it is a very large project: [deleted]

All of the changes I made were only on the tutorial scene, so I have not checked any of the others.

Hope this is helpful!

4 Likes

Thank you so much, this was a group project I did most of the coding for so I had to try and pull from my other projects to try and fill the deadline. Thank you!