How do I play animation based on Global NR?

0 favourites
  • 7 posts
From the Asset Store
Globals 2.0
$3.99 USD
Globals 2.0 stores and group variables. You can also load and save data (variables) from/to JSON files.
  • Greetings there! ^_^

    So i have about 55 animations that needs to be played, depending on *items*.

    Now, it is a bit too long to do;

    ''When button Q is pressed''

    ''If (Global Variable is 1) = Play animation 1.

    ''If (Global Variable is 2) = Play animation 2.

    ''If (Global Variable is 3) = Play animation 3.

    And so on, and so on.

    So my question is, can animation be played by a Global Variable number? For example;

    'When Q button is pressed''

    ''Set animation to *(the variable)*''

    So if variable is 1, it plays animation 1, if the variable is 2 then play animation 2 and so on? Or do i have to take the long way by IF and do's?

    Thanks alot ^_^

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Basically to play Animation 1 if Variable is 1

    Play animation 2 if Variable is 2. Etc

  • Yes, I do this all the time. What I do is make the value of the variable the same as the animation name, then you can make an event like this:

    On Q pressed set player var_animation to "animationname"

    (whatever trigger you like) set player animation to player.var_animation

    or

    If player var_animation="walkleft" set animation to player.var_animation

  • Yes, I do this all the time. What I do is make the value of the variable the same as the animation name, then you can make an event like this:

    On Q pressed set player var_animation to "animationname"

    (whatever trigger you like) set player animation to player.var_animation

    or

    If player var_animation="walkleft" set animation to player.var_animation

    Hehe hey, this is so good to hear!! But i dont quite understand what u mean.

    When character jump, depending on item equipped, a different animation plays (on the effect)

    So as far as i understand it, the Variable has to be the same name as the effect right?

    So ability name: BootsFX

    Global Variable name: BootsFX

    If player equips Boot 2 -> Set BoostFX (Variable) to 2.

    If player equips Boot 5 -> Set BoostFX (Variable) to 5.

    When HeroX performs ''jump'' - Set animation to BoostFX? The variable that is?

    (If the boots equipped is Boot 2 (BoostFx2) - If i play the Animation in Variable, will it be BoostFx2 Effect??

  • There are literally dozens of ways to do this. You'll need to experiment and find the way that works the best for you. I've put together a capx of one way for you to hopefully get you started.

    https://www.dropbox.com/s/ox5igc3xe1bin ... State.capx

    EDIT: I just noticed that you said you wanted an effect animation to change, not the player animation. In that case, you would do it the exact same way as shown in the capx, just add the variable etc to the effect sprite rather then the players. I've updated the above capx with an example.

  • There are literally dozens of ways to do this. You'll need to experiment and find the way that works the best for you. I've put together a capx of one way for you to hopefully get you started.

    https://www.dropbox.com/s/ox5igc3xe1bin ... State.capx

    EDIT: I just noticed that you said you wanted an effect animation to change, not the player animation. In that case, you would do it the exact same way as shown in the capx, just add the variable etc to the effect sprite rather then the players. I've updated the above capx with an example.

    Hehe hey!! Gotcha now!! ^_^ - Thanks alot for this!! You really took your time man, very much appreciated!! ^_^

    Thanks! <img src="{SMILIES_PATH}/icon_e_biggrin.gif" alt=":D" title="Very Happy">

  • You're welcome. If you have any issues relating to this, feel free to get in contact with me. I've already worked through most of them myself and I would be happy to help if needed.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)