Animation switching/swapping
QuinnZoneStudios
Member Posts: 452
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
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
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.
Send and Receive Data using your own Server Tutorial! | Vote for A Long Way Home on Steam Greenlight! | Ten Years Left
Thanks again!
http://gamesalad.com/game/play/37013
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
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
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!
Thanks for the good wishes also.
Now on to my giant fly swatter lol!
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
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 :-)
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
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!