Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: croquetasesina on Sat 13/04/2019 14:25:40

Title: animate a secondary character while the protagonist can be used
Post by: croquetasesina on Sat 13/04/2019 14:25:40
Hello! I would need a secondary character to make an animation constantly (imagine two characters talking, but without text, only the animation) while the protagonist continues to act in the room.
I have tried with the following code:

Code (AGS) Select

function room_AfterFadeIn()
{
cJuan.LockView(34);
cJuan.Animate(2, 5, 0, eNoBlock, eBackwards);
Wait (70);
cJuan.UnlockView();
Wait (10);
cPeter.LockView(42);
cPeter.Animate(1, 5, 0, eNoBlock, eBackwards);
Wait (70);
cPeter.UnlockView();
Wait (10);
}


However, the protagonist can't move while the animation is in progress.

What would be the best way to get what I want? And how could I make the action repeat itself every X time?
Title: Re: animate a secondary character while the protagonist can be used
Post by: Cassiebsg on Sat 13/04/2019 14:40:15
Well, of course the protagonist can't move, since you telling the game to "wait", when you wait you are blocking.

If the action will have to be repeated every x times, then you'll need a timer.
Start the timer at room start, or after fadein, and in rep_exe check for if the timer has expired, when expired set the animation in motion again.

To make the characters act in the BG, you need to start them moving (non-blocking) at room_start or afterfadein, and then check in rep_exe if they are animating, and if not, you just tell them to animate again. make sure you add repeate.

Also, why are you locking and unlocking the animation?

If you want them to keep repeating the actions, lock their view then "cJuan.Animate(2, 5, eRepeat , eNoBlock, eBackwards);"
Then in rep_exec, just check if (!cJuan.Animating) cJuan.Animate(2, 5, eRepeat , eNoBlock, eBackwards);

EDIT: Okay, technicaly you don't even need to start them animating at room_start or afterFadeIn... since the rep_exec will pick up and start the animation... so just do the rep_exe line and see if that solves your problems