I am a high school video game design teacher. Due to Covid we have gone remote and students do not have access to our usual program on their Chromebooks. I have searched for months for an online editor and discovered PlayCanvas! The kids love it, but I have had a short time to learn (I am only a few days ahead of them).
I am working on a project similar to one we do in class. For the project, we do 5 different levels. I have looked at other projects, searched for answers on how to change scenes, but I can not get it to work. When I get to the end of the plane, I have a trigger that when the player hits it should go to the next level. I am on day 4 of trying to find an answer and I can get close, but I canāt the trigger to work. If anyone could help a teacher out, I would greatly appreciate it! Thank you!
Well, considering the scenes are simple, you can make it easier - donāt use multiple scenes. In fact, there is little benefit from using multiple ones, instead of a single one, since they are still in the same scene graph.
What you can do is arrange your scene so that each level environment would be under their own node:
So, when the player reaches the end trigger, you can easily disable current level node (.e.g. Level 1) and enable the next one (Level 2). And then teleport the player to the start of the level 2.
The issue is that because your āendā entity has a rigidBody, it is not a trigger so none of the trigger events will be fired. Remove the rigidbody and you should be good to go.
I took the rigidbody off (just disabled it). The player entity kept going and didnāt return. I appreciate your help.
I have seen that in other projects. I will check it out. I appreciate your help. I was trying to do the project in the same fashion as our other program.
You have to remove it, not disable it. See working version here for the scene change: https://playcanvas.com/editor/scene/1054893
Great! Thank you. I thought disabling would do the same thing (still learning). My only issue now is the player gets to the next level, it doesnāt move and is twitching. Thoughts?
Thereās a bit of code that is teleporting the player back to a position on every rigidbody collision. So every time the player hits the floor, it is getting teleported back.
DynamicBody.prototype.onCollisionStart = function (result) {
if (result.other.rigidbody) {
this.entity.rigidbody.teleport(this.rpoint.getPosition());
this.entity.rigidbody.linearVelocity = pc.Vec3.ZERO;
}
// this.state = 'die';
// this.entity.sprite.play('die');
};
You probably want to use entity tags and check what it is colliding with first before teleporitng.
Thank you. It does work now! I appreciate your quick response and help. I am so excited (literally jumping up and down). Now I can and create the tutorials for my students.
Hey great to so see a teacher so enthusiastic about this!
Thanks. I love my job. And the first time I heard a kid say, āThis is like a real game.ā I was over the moon. It is so fun to see them make these connections and to be proud of what they made.