[Solved] randomly play different animations

0 favourites
  • 9 posts
From the Asset Store
Adjusting the game screen for different resolutions (Letterbox scale)
  • I have this animal that I want to blink it's eyes but only randomly. I'd like it to be seamless so it seems like maybe if there were some "on completion of animation" event i could randomly pick a number after each the main idle animation complete and if the number is a certain number, then it would play that other animation and when that completes, random again.. over and over.

    I just don't see how i can achieve that looking at an objects animation options. Any suggestions?

    Thanks!

    Caleb

  • On animation ended (animation name) set variable1 to Random()

    If Variable1 = whatever start animation2

    On animation2 ended start animation 1

  • Take the eyes out of the sprite. and have it pinned to your main character.

    Then use an event to animate eyes independently.

    Go look here for some inspiration:

    scirra.com/forum/tutorial-camera-fx-limbo-look_topic40427.html

  • I use the variable method for my game. The main character in my game can strike in 4 directions, but a random animation is played every time to keep things dynamic. For every strike a given variable gets assigned a random number between 1-10.

    To use this variable with your animations, you must first name your animations accordingly. The animations are for instance called LeftHit_1, LeftHit_2 etc.

    The string to trigger this is: "LeftHit_"&VariableWithMagicNumber

    Hope this helps.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Instead of using a variable number you could also use:

    choose("blinkfast","blinkleft","blinkslow")

    that way you can just use the animationnames you want.

  • oh wow that's so cool that you can just plug in objects names like that LittleStain! i love it.

    i don't know if I understand how to do that "on end". where would I access that event? I don't recall seeing that anywhere I've been in but maybe i'm looking in the wrong place?

    thanks!

    Caleb

  • I'm not sure objectnames would work as expected.

    Strings and numbers work great.

  • Hi part12studios,

    go to the animation category of events in your object and look for "On Finished". I guess that is what bluephase ment :)

  • ok awesome that worked great! I get it now and got it working similar to how you suggested! Yea I just hadn't noticed the animation options until you clearly pointed them out. Thanks a bunch for your help on this. This opens up a lot of other fun possibilities :)

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