Hi,
here is the exact JavaScript code used in the game. I added some comments as well.
// start position of the player
var startPos = {x: 0, y: -30, z: 15};
// get camera object which represents the player
var cam = Scene.getCamera();
var camPos;
// for every frame...
Scene.scheduleRepeating(function() {
// ...get the position of the camera
camPos = cam.getPosition();
// if the z-coordinate (height) is less than 2...
if(camPos.z < 2) {
// ...set the camera position to the start position
cam.setPosition(startPos.x, startPos.y, startPos.z);
}
}, 0);
The idea is:
1. Determine a start position of the player which consists of the three space coordinates x, y and z. This depends on your level.
2. For every frame -> check if the players z-position (the camera object) is less then lowest platform in your game.
2.1. If this is the case, the player fell and you need to reset the position of the player.
Benjamin