Sonic die when falling

Hey sorry to bother, but how do i make sonic reset to the beginning when he falls because then you just keep on falling and falling

Hi @Gabriel_Dobrzynski,

You will want to create a Trigger Volume below your level:

Keep in mind that this volume will only respond to other colliders, but I’m assuming that Sonic already has one.

You can see in the code example that when Sonic’s collider enters the trigger volume, it will fire an event (‘triggerenter’) which passes Sonic’s entity along. From there you can then use the event to move Sonic back to the beginning and any other operations you might need to do at the same time.

1 Like

I’ve added that but still doesnt work? @eproasim


Could you please post the project or the script you are using? That will be very helpful.

Sure! I have deleted it because my friend doesnt know if it will work (edit: i have put it back)

Hi @Gabriel_Dobrzynski,

I didn’t see a collider objected created below your level. You will want to create a collider object that is big enough to cover wherever Sonic may fall off of the world.

I took a look at the script you had in your files and noticed that you were declaring two different scripts. You will want to keep the original one you are declaring, and subscribe to the ‘triggerenter’ and "triggerleave’ events like in the example below. You should be able to copy and paste that code directly into your PlayerReset script.

Once you have done this, you will need to assign that script to the collider you created below your world. Now when Sonic makes contact with the collider, you will see that event logged in the console. From there you can dig into the entity object that is passed, and reset the location of the player as you wish.

var PlayerReset = pc.createScript('playerReset');

// initialize code called once per entity
PlayerReset.prototype.initialize = function() {

    this.entity.collision.on('triggerenter', function (entity) {
        console.log( + ' has entered trigger volume.');
    this.entity.collision.on('triggerleave', function (entity) {
        console.log( + ' has left trigger volume.');

// update code called every frame
PlayerReset.prototype.update = function(dt) {

// swap method called for script hot-reloading
// inherit your script state here
// PlayerReset.prototype.swap = function(old) { };

// to learn more about script anatomy, please read:

You can also use a normal static collision and use collisionstart as well.