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](/_next/image?url=%2F_next%2Fstatic%2Fmedia%2Fsnippet_physics-body.a07c5968.png&w=1920&q=75)
![change-avatar-speed_boost](/_next/image?url=%2F_next%2Fstatic%2Fmedia%2Fchange-avatar-speed_boost.2ae557a6.gif&w=2048&q=75)
Place objects wherever you want
Place the object where you want it.
![change-avatar-speed_boost-item](/_next/image?url=%2F_next%2Fstatic%2Fmedia%2Fchange-avatar-speed_boost-item.96a49d3a.png&w=3840&q=75)
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
});
}