Create, Compete & Win at Redbrick Connect 2024! 🎉
SnippetAvatar speed change

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!

Physics -> Body


Result

Place objects wherever you want

Place the object where you want it.


Boost Item

Code

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

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
  });
}