Animating two objects at the same time

Started by TheEyess, Tue 17/10/2023 22:37:57

Previous topic - Next topic

TheEyess

Hey,

I'm wondering if there is a way to animate two objects in one room at the same time. I have two object animations that work fine by themselves and when played one after the other, but I'd like them to play at the same time, is this possible? I realize this probably is a really basic scripting question.

Thanks in advance for any help! :)

Pax Animo

#1
Heya there TheEyess, maybe something like:

Code: ags
function room_Load() {
    Object[1].Animate(0, eOnce, eNoBlock);
    Object[2].Animate(0, eOnce, eNoBlock);
}

After Object[1].Animate(the loop you want to play. Then if you want it to play once or repeated. Then if it blocks other interactions or not.

Also you may need to set each objects view for which animation they play or the loop within the same view.

exp
Code: ags
Object[1].SetView(1);

Edited: To allow two objects to run without blocking
Misunderstood

Crimson Wizard

#2
Playing 2 animations at the same time would require to call the first Animate with eNoBlock.

Code: ags
    // replace with your real object names and view names
    oFirstObject.SetView(VANIMATION1);
    oAnotherObject.SetView(VANIMATION2);
    oFirstObject.Animate(0, eOnce, eNoBlock);
    oAnotherObject.Animate(0, eOnce, eBlock);

This will schedule first animation and immediately continue to the next command.

I do recommend using scriptnames for objects and views instead of their indexes, as that's safer and less prone to errors.

Pax Animo

Hey Crimson, always the helping hand <3

Wouldn't it be oFirstObject rather than cFirstObject
Misunderstood


TheEyess

Quote from: Crimson Wizard on Wed 18/10/2023 00:03:01Playing 2 animations at the same time would require to call the first Animate with eNoBlock.

Code: ags
    // replace with your real object names and view names
    oFirstObject.SetView(VANIMATION1);
    oAnotherObject.SetView(VANIMATION2);
    oFirstObject.Animate(0, eOnce, eNoBlock);
    oAnotherObject.Animate(0, eOnce, eBlock);

This will schedule first animation and immediately continue to the next command.

I do recommend using scriptnames for objects and views instead of their indexes, as that's safer and less prone to errors.

Thank you both! The eNoBlock option was the thing i was missing, thank you so much, Crimson! Working as intended now :)

SMF spam blocked by CleanTalk