How to make pet move without delaying other instructions?

I want to make the pet go some places on the map while my soldiers are attacking and such but using
pet.move delays the next instruction. How could I make pet move and not delay the code?

here is an example for my function

let flag = () =>{
    var flag = hero.findFlag("green");

 if(flag){
     pet.moveXY(flag.pos.x, flag.pos.y);
     }
    };

Use the pet.on(“spawn”,function) that controls your pet simultaneously with your hero.

1 Like

yep like this:
this is python, ask someone to translate it.

def onSpawn(event):
    unit = event.target
    flag = hero.findFlag("green")
    if flag:
        unit.moveXY(flag.pos.x, flag.pos.y)
pet.on("spawn", onSpawn)
1 Like

thanks

let onSpawn = (event) => {
unit  = event.target;
flag = hero.findFlag("green");

if(flag){
unit.moveXY(flag.pos.x, flag.pos.y);
}
}
pet.on("spawn", onSpawn)

this should do the trick