Assign random animations to collided objects?

BothaBotha Member Posts: 8
edited November -1 in Working with GS (Mac)
So I'm working on a breakout type game and I want my actors (which are characters instead of bricks) to react a little differently each time they collide with the ball. I have already made several different animations for each character but I'm not sure how to set up the rules to make this work correctly in the game. If anyone can help I'd appreciate it! I'm assuming has something to do with change image and using a random setting but I'm not sure how set it up with the expression editor!

:)

Comments

  • quantumsheepquantumsheep Member Posts: 8,188
    Make an attribute on the actor itself. Call it RandAnim (or something)

    Then, when the actor's hit (overlaps or collides with ball, I'd imagine) put in:
    Timer:
    after .1 seconds
    Rule:
    Change attribute self.RandAnim to Random (1,5) (the five can be replaced with the number of variations you have).

    Then put in your rules for animations:
    If self.RandAnim = 1
    Play animation 1

    If self.RandAnim = 2
    Play animation 2

    And so on

    That should give you a good start. Hope it helps!

    QS :D

    Dr. Sam Beckett never returned home...
    Twitter: https://twitter.com/Quantum_Sheep
    Web: https://quantumsheep.itch.io

  • BothaBotha Member Posts: 8
    Thank you so much quatumsheep! I'm going to try this out! I'm sure it will work but I have a second follow up question which relates to to same thing. How would I have to set it up to just make my character play a random animation without any collisions rules? The reason I as is that I've made a whole lot of little animations of characters that I want to play randomly but want space in between where they return to their static state so they aren't constantly moving. For example I have an animation of a character blinking that is 6 frames long. I want him to blink at random intervals and not be constantly looping the six frames. I could put static frames at the end of the animation but then the looping would be fixed and it would take up way more memory. What do you think? Is it possible? Thanks a thousand times over again for the help!!!!!!! :)
Sign In or Register to comment.