Activate a Director

ruimac

Member
Imagine the following:

I have a main director named "Default".
I have a second director named "ANIM1"

I have an action keyframe in director "Default" that shows frame 0 of director "ANIM1" and performs a CONTINUE of director "ANIM1"
I also have a Stop tag in the same frame number of the "Default" director so that the animation stops in the "Default" director and the "ANIM1" director starts playing when the action keyframe in the "Default" director is reached.

I also have a Stop tag in the "ANIM1" director and the animation stops there, like I want.

But when I press "Continue", the animation continues in the "Default" director. What I wanted was that, the "Continue" now continued from where it stopped in the "ANIM1" director, since it was the last one being animated.

How can I force the "ANIM1" director to be the one active now, making sure that the "Continue" button will continue the "ANIM1" animation, not the "Default" animation?
 
you can try something like this in your action keyframe:
Code:
THIS_DIRECTOR SHOW 0.9;
THIS_DIRECTOR CONTINUE;
THIS_SCENE*STAGE*DIRECTOR*ANIM1 CONTINUE

1762163847809.png
in this example the default director is locked in a loop that continues the ANIM1 dir every time continue received.
 
But I need the default director to continue, after the ANIM1 animation finishes.
However, my ANIM1 director has a Stop in the middle.
So, what I need is:

1 - Default director action will start animation of ANIM1 director.
2 - ANIM1 animation plays until the Stop is reached.
3 - Pressing continue will continue the ANIM1 animation until the end (but should not continue the Default director animation)
4 - When the ANIM1 animation finishes, the Default director animation can continue.

My only problem, so far, is that, at step 3, when I press Continue, the Default director animation continues, instead of the one in ANIM1.
 
is ANIM director sub director to Default dir? if not, why not adding a stop to default dir?
 
No, ANIM1 is not a sub-director to Default.
I just want to play ANIM1 when an action in the Default director tells it to.
There will also be ANIM2, ANIM3, ANIM4... directors. And each one should only play when an action in the Default director tells it to.
Also, after each ANIM (1, 2, 3, etc) finishes, I want the animation to continue in the Default director to continue from where it stopped.

For example:

When the playhead reaches A, it stops at the Stop tag and the Action makes the ANIM1 director start.
The animation of ANIM1 plays until it reaches the Stop tag at B.
Now, I would like to play the rest of the animation until C and then continue the animation from A to D.
The problem is that when the animation stops at B, if I press Continue, the playhead continues from A.
My "chicken-wire" solution was to place an Action right after the Action at frame A, that forces the ANIM1 director to continue.
But I would like it to finish the animation from B to C when I press Continue, and only after that go on from A to D.
I know I can place an Action at C that tells the Default director to continue. But my problem is that as soon as I press Continue at the Stop at B, the playhead goes on from A, not from B.

stage.jpg
 
I can recommend that instead of the stop point in your Default director, set the following:
  1. A tag named "stop1"
  2. Under it, an action keyframe to trigger the ANIM1 director:
    Code:
    THIS_SCENE*STAGE*DIRECTOR*$ANIM1 START;
  3. One frame after that action keyframe, add another one with the command:
    Code:
    THIS_DIRECTOR SHOW $stop1;
  4. One frame after that action keyframe, add another tag named "continue1"
  5. And at the end of your ANIM1 director, set an action keyframe to continue the Default director:
    Code:
    THIS_SCENE*STAGE*DIRECTOR*$Default SHOW $continue1;
    THIS_SCENE*STAGE*DIRECTOR*$Default CONTINUE;
It's a bit cumbersome, but it will solve your issue.

1762273906969.png
 
I can recommend that instead of the stop point in your Default director, set the following:
  1. A tag named "stop1"
  2. Under it, an action keyframe to trigger the ANIM1 director:
    Code:
    THIS_SCENE*STAGE*DIRECTOR*$ANIM1 START;
  3. One frame after that action keyframe, add another one with the command:
    Code:
    THIS_DIRECTOR SHOW $stop1;
  4. One frame after that action keyframe, add another tag named "continue1"
  5. And at the end of your ANIM1 director, set an action keyframe to continue the Default director:
    Code:
    THIS_SCENE*STAGE*DIRECTOR*$Default SHOW $continue1;
    THIS_SCENE*STAGE*DIRECTOR*$Default CONTINUE;
It's a bit cumbersome, but it will solve your issue.

View attachment 221868

So, basically, instead of a Stop in the Default director, I would create a loop, and an action in the ANIM1 director would get the Default director aout of the loop.
But, going back to Stop1 would to trigger the ANIM1 animation from the start?
 
I'm not sure how you planned to stop the other directors (ANIM2, ANIM3, etc.) from playing when you press Continue.
After testing a few options, I found that using a script is the cleanest solution.
Add the following script to your root container:

Code:
dim defaultDir as director
dim stopKfName as string = "stop"
dim animDirName as string = "ANIM"

sub OnInit()
    defaultDir = stage.findDirector("Default")
end sub

sub playStopAnimation(index as string, state as boolean)
    
    'get the kf in default director
    dim tempKf = defaultDir.findkeyframe(stopKfName & index)
    
    'if the state is to 'play'
    if state then
        'show it's time + one frame forward
        defaultDir.show(tempKf.time + 0.02)
        'continue default
        defaultDir.continueAnimation()
    'state is stop
    else
        'show it's time, one frame backward
        defaultDir.show(tempKf.time - 0.02)
        'stop default
        defaultDir.stopAnimation()
        
        'get the ANIM direcror
        dim animDir = stage.findDirector(animDirName & index)
        if not animDir.isAnimationRunning() then
            'show the frame after the stop action keyframe
            animDir.show(animDir.findKeyFrame("stop").time + 0.02)
            'continue ANIM dir
            animDir.continueAnimation()
        end if
    end if
end sub
In the Default director
Instead of placing a normal stop tap, create an action keyframe named stop1 (or stop2, stop3, etc., matching the index).
Set this command in the keyframe:
Code:
THIS_SCENE*TREE*$script*SCRIPT INVOKE playStopAnimation 1 0;
  • Change the first number to match the ANIM director you want to start.
  • 0 means stop the Default director and start the selected ANIM director.

In each ANIM director

  1. On frame 0 add a blank tag
  2. On frame 1 add an action keyframe named "stop" with this command:
    Code:
    THIS_DIRECTOR SHOW START;
    THIS_DIRECTOR STOP;
  3. At the end of the ANIM director add another action keyframe with this command:
    Code:
    THIS_SCENE*TREE*$script*SCRIPT INVOKE playStopAnimation 1 1;
    • Change the first number to the stop index you want to resume from.
    • 1 means continue the Default director again.
I've attached a via file with an example, hope it will help
 

Attachments

  • playAnimDir.zip
    19.4 KB · Views: 6
I'm not sure how you planned to stop the other directors (ANIM2, ANIM3, etc.) from playing when you press Continue.
After testing a few options, I found that using a script is the cleanest solution.
Add the following script to your root container:

Code:
dim defaultDir as director
dim stopKfName as string = "stop"
dim animDirName as string = "ANIM"

sub OnInit()
    defaultDir = stage.findDirector("Default")
end sub

sub playStopAnimation(index as string, state as boolean)
   
    'get the kf in default director
    dim tempKf = defaultDir.findkeyframe(stopKfName & index)
   
    'if the state is to 'play'
    if state then
        'show it's time + one frame forward
        defaultDir.show(tempKf.time + 0.02)
        'continue default
        defaultDir.continueAnimation()
    'state is stop
    else
        'show it's time, one frame backward
        defaultDir.show(tempKf.time - 0.02)
        'stop default
        defaultDir.stopAnimation()
       
        'get the ANIM direcror
        dim animDir = stage.findDirector(animDirName & index)
        if not animDir.isAnimationRunning() then
            'show the frame after the stop action keyframe
            animDir.show(animDir.findKeyFrame("stop").time + 0.02)
            'continue ANIM dir
            animDir.continueAnimation()
        end if
    end if
end sub
In the Default director
Instead of placing a normal stop tap, create an action keyframe named stop1 (or stop2, stop3, etc., matching the index).
Set this command in the keyframe:
Code:
THIS_SCENE*TREE*$script*SCRIPT INVOKE playStopAnimation 1 0;
  • Change the first number to match the ANIM director you want to start.
  • 0 means stop the Default director and start the selected ANIM director.

In each ANIM director

  1. On frame 0 add a blank tag
  2. On frame 1 add an action keyframe named "stop" with this command:
    Code:
    THIS_DIRECTOR SHOW START;
    THIS_DIRECTOR STOP;
  3. At the end of the ANIM director add another action keyframe with this command:
    Code:
    THIS_SCENE*TREE*$script*SCRIPT INVOKE playStopAnimation 1 1;
    • Change the first number to the stop index you want to resume from.
    • 1 means continue the Default director again.
I've attached a via file with an example, hope it will help
It seems like a nice solution.
However, when the play-head stops at the stop in then ANIM1 director, when I press continue, it restarts the animation of ANIM1 from frame 0.
 
if not animDir.isAnimationRunning() then
This is what this line is intended to prevent, I've tested it in 3.14 and 5.3.2 and and couldn't recreate this behavior
How did you tested your scene? have you checked my example?
 
Last edited:
Back
Top