Character speed change period under certain conditions

To change movement speed of an PLAYER, you can use PLAYER.changePlayerSpeed(1), by default speed is 1. More information about avatar api can be found here

๐Ÿšซ

Donโ€™t forget to check Body in the objectโ€™s properties panel to use methods like onCollide()!

snippet_physics-body Physics > Body


change-avatar-speed_boost Result

Place objects wherever you want

Place the object where you want it.


change-avatar-speed_boost-item Boost Item

Code

BoostItem
const boost = WORLD.getObject("boostTitle");
 
function Start() {
  // use here PLAYER related logic
  boost.onCollide(PLAYER, () => {
    boost.kill();
    //change PLAYER speed
    PLAYER.changePlayerSpeed(2);
  });
}

Make it fast for 3 seconds when you eat a specific item

BoostItem
const boost = WORLD.getObject("boostTitle");
 
function Start() {
  // use here PLAYER related logic
  boost.onCollide(PLAYER, () => {
    boost.kill();
    //change PLAYER speed
    PLAYER.changePlayerSpeed(2);
    setTimeout(() => {
      PLAYER.changePlayerSpeed(1);
    }, 3000); //wait 3 seconds
  });
}