x


Turn off interaction while certain animations are playing

I'd like to create animations, where the user should only be able to provide gui input at specific times in the animation. He should however not be able to move or rotate freely within the scene, i.e. no cursor or mouse navigation.

What's necessary to do that?

Thanks, flexrails

more ▼

asked Nov 17 '09 at 11:37 PM

flexrails gravatar image

flexrails
706 29 35 55

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

In the script that takes care of the cursor or mouse navigation, you can make a conditional, like this:

var allowNavigation : bool = true;

if (allowNavigation == true) {
    ... your cursor or mouse navigation code here ...
}

You can then switch that variable, allowNavigation, off and on based on timing in the animation. A few ways to do that:

  • In Update(), check if the time of the animation state is within certain values, like this:

    var animTime = animation["myClip"].time;
    if (animTime > turnOffTime && animTime < turnOnTime) {
        allowNavigation = false;
    else {
        allowNavigation = true;
    }
    
  • Use the Animation View to add AnimationEvents in the animation clip which call a function that can turn allowNavigation on and off.*

  • Use the Animation View to animate the allowNavigation variable directly. A value of 0 mean false and 1 means true. You can use stepped interpolation.*

*** These solutions doesn't work on imported animation clips, since they are read-only. However, they work on animations created directly with the Animation View, or on duplicates of imported animations.

more ▼

answered Nov 18 '09 at 12:35 AM

runevision gravatar image

runevision ♦♦
8.1k 29 46 112

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x3768

asked: Nov 17 '09 at 11:37 PM

Seen: 1285 times

Last Updated: Dec 22 '09 at 10:52 AM