для этого будем просто повышать скорость передвижения
можно было бы конечно по другому возможно потом переделаю
export default function controllerComp(joystick) {
return {
id: "controllerComp",
require: ["pos"],
attackSpeed: 1000,
defaultSpeed: 200,
speed: 200,
add() {
},
update() {
this.move(joystick.direction.scale(this.speed))
if (joystick.direction.x)
this.flipX = joystick.direction.x < 0
},
}
}Для этого сначала в controllerComp создаём свойства для скорости обычной и во время атаки
а затем просто изменяем скорость в animatorComp
this.onStateEnter("bite", () => {
this.speed = this.attackSpeed
this.play("bite")
})
this.onAnimEnd((anim) => {
states2.forEach((key) => {
if (anim == key) {
this.speed = this.defaultSpeed
this.enterState("idle")
}
})
})