Animation switching/swapping

QuinnZoneStudiosQuinnZoneStudios Member Posts: 452
edited November -1 in Working with GS (Mac)
Hey Saladeers,
I have several animations that I'm switching between. I've looked at the platformer template demo and the entries in the forum here about change attribute behaviors and Boolean attributes. Well it seems I have success with two animations at a time but introducing a third and beyond has the animations flipping back and forth again as it can't decide which one to play.
I assume this can be done but I'm only partially getting it right.
It probably doesn't help that I have flying states and standing/idle states that can both be interrupted by several short animations.
Also I see sometimes Change Attribute is set to true or false and other times 0 or 1. Can it be either or does it actually matter?
Thanks in advance for any insights,
Mike

Comments

  • jonmulcahyjonmulcahy Member, Sous Chef Posts: 10,408
    change attribute can be anything, it just depends on the attribute type you're using. If it's a boolean, you'll use true/false. If it's an integer, use 0 or 1.

    As far as the animations go, can you upload a basic project showing what you're trying to do? That way we can take a look.
  • QuinnZoneStudiosQuinnZoneStudios Member Posts: 452
    Cool. I uploaded my animation test if anyone is able to point out my huge coding mistakes lol!
    Thanks again!

    http://gamesalad.com/game/play/37013

    Mike
  • QuinnZoneStudiosQuinnZoneStudios Member Posts: 452
    Any brave souls out there willing to take on my Booleans....???
  • firemaplegamesfiremaplegames Member Posts: 3,211
    Hi Mike!

    So i started looking at your project...
    Right now, you have all of your movement functions and all of your animation functions all tangled up together, plus every Rule has something in the OTHERWISE section. Lots of Timers with "After 0 seconds...". etc..

    It doesn't need to be that complicated.

    So the first thing I did was to untangle your Rules.

    First, simply get your movement functioning correctly, you don't worry about the animations just yet.

    There is gravity pushing down on Buzby with an Acceleration Behavior (like you had)
    I changed the left and right movements to be Accelerations as well, and added Down too, just in case you need to dodge something quickly...

    That takes care of the movement. You don't need any code in the OTHERWISE sections.

    Next, you have each "state" as a separate Boolean Attribute: Flying/Idle/Yikes/Ouch/etc... This very quickly (as you could probably tell) gets hard to manage. If you turn Flying to TRUE, you have to turn Idle to FALSE, and on an on...

    An easier way to think about that is to think of Buzby having "states". He can only be in one state at a time. Either he is in the Flying state, or the Idling state, or the Victory Roll state, etc..

    This can easily be controlled with an Integer Attributed called something like AnimationState. 0 = Flying, 1 = Idle, 2 = Victory Roll, etc...
    And it is very easy to add new states as you need them. "Oh, I need a Death state?" That will be number 5.

    So I stripped out your Booleans and replaced it with an AnimationState Attribute.

    Then I created a Group of Rules to control his current state:
    If Buzby hits a Ouch trigger, switch his state to 4
    If Buzby hits a Yikes trigger, switch his state to 3
    If Buzby's Y velocity = 0, switch his state to 1

    And FINALLY, I set the animations based on the current animation state.

    Hopefully it is easy enough to understand!

    There are three groups of Rules:

    Movement
    Setting the Animation State
    Showing the current Animation

    Here is the updated project:
    http://gamesalad.com/game/play/43905

    FYI, You'll need to create separate ground and border actors, as it is right now, you can push Buzby into the walls or ceiling, causing him to stop - thus triggering the Idle animation state.

    Hope this helps!
    Joe
  • QuinnZoneStudiosQuinnZoneStudios Member Posts: 452
    Okay this is a really exciting breakthrough for me as I've been struggling with tests on this all week lol!
    Sorry to take up your valuable time with this Joe as I know you are extremely busy.
    Hope to return the favor before too long!
    Profuse thanks for your awesomeness!!!

    Oh yes I indeed need to have my floor be different to my walls/ceiling (thanks for pointing that out)

    Mike
  • firemaplegamesfiremaplegames Member Posts: 3,211
    Cool! I'm glad I could help!

    Yeah, my advice would just be to keep everything separate.
    That way, you can tackle each idea/function as a separate chunk.

    If you want to tweak the Movement functions, you're not tripping over the animations and vice-versa.

    It allows you to focus on one problem at a time.
    "Well, my laser attack is all screwy, but AT LEAST my movement works perfectly..."

    Good luck with your game!
  • QuinnZoneStudiosQuinnZoneStudios Member Posts: 452
    It's perfect. I re-uploaded your version and overwrote mine. I'm going to leave it up as a demo for others to learn from. You can leave your version up if you like, either way is fine by me.
    Thanks for the good wishes also.
    Now on to my giant fly swatter lol!
  • QuinnZoneStudiosQuinnZoneStudios Member Posts: 452
    Hey Joe (or anyone who may have an answer),
    I'm finding this animation test:
    http://gamesalad.com/game/play/43905
    Runs fine within the editor but remains frozen at the first frame when testing on the iPhone, no gravity or flying. So there seems to be something blocking it from beginning. I wonder if another rule should be entered to make sure it starts, but I don't know what? I've played around with a bunch of things but nothing seems to help.
    Why would it work great in the editor but no on the iPhone I wonder?
    As usual I'm sure theres a simple answer....
    Mike
  • firemaplegamesfiremaplegames Member Posts: 3,211
    hmmm... yeah, that's weird. I'll try and see what's up...
  • QuinnZoneStudiosQuinnZoneStudios Member Posts: 452
    Heh, thanks!
    Of course I realize there are no iPhone controls but the first part should still run. In the real game I have button attributes you can press on the iPhone for left, right and up.
    Good luck sir :-)
  • firemaplegamesfiremaplegames Member Posts: 3,211
    OK, found it...you're just trying to test me!

    In your Border Actor, there is an unnecesary Rule that tells it to Collide with itself...

    Delete that Rule and it will work fine.

    Don't know why it works in preview but not on the phone?

    Joe
  • firemaplegamesfiremaplegames Member Posts: 3,211
    To find fun bugs like that, just start deleting things until it works. It will narrow down the suspects!
  • QuinnZoneStudiosQuinnZoneStudios Member Posts: 452
    Lol! Sorry Joe ..er.. you passed.
    I'll take a look at that now.
    By the way, If there's ever anything I can do for you (like stop bugging you with trivialities and foolishness) let me know.
    Thanks for your willingness to share superior knowledge. If only I weren't left brain dead.... sigh....
    Mike

    *Edit* Yup that runs great now. So the lesson learned is that a behavior or attribute that conflicts with itself may still run in the GS editor but the iPhone build is less forgiving and therefore freezes any running of the game. Good to know!
Sign In or Register to comment.