Multiple Animation Sequences and Interactions
adobson66
Member Posts: 11
Hey everyone I'm relatively new to this program. A long time ago I made a small PC Desktop program that let an animated character walk around and do random things. You could click on him and he'd do different animations and stuff.
I'm not very good at programing complex gameplay, so I thought it would be easy to translate my character into an iphone/ipod touch "game." And coincidentally all of his original sprites just happen to fit the size constraints perfectly.
The problem I am having is that I don't know what the best way would be to work out his animation sequences. He needs to be able to randomly pick an animation after a short period of time if you don't touch him to make him feel alive. He also can't be allowed to go into another animation if you've already got one going.
What I've been able to do right now is make each separate animation it's own "actor" and when you touch the screen it spawns the new actor and deletes the old. And when the new actor ends it's animation (via a timer) it deletes itself and respawns the old actor. This works great if you're just going from one animation to another, but not so for randomly picking an animation upon touching.
Thus far I have 2 animations for when you touch him but it's finicky for which one it'll pick. You can view what I've got done here: http://gamesalad.com/game/play/65221
Ps: For some reason even in Safari I can't get this thing to play properly, so I hope everyone else can.
I'm not very good at programing complex gameplay, so I thought it would be easy to translate my character into an iphone/ipod touch "game." And coincidentally all of his original sprites just happen to fit the size constraints perfectly.
The problem I am having is that I don't know what the best way would be to work out his animation sequences. He needs to be able to randomly pick an animation after a short period of time if you don't touch him to make him feel alive. He also can't be allowed to go into another animation if you've already got one going.
What I've been able to do right now is make each separate animation it's own "actor" and when you touch the screen it spawns the new actor and deletes the old. And when the new actor ends it's animation (via a timer) it deletes itself and respawns the old actor. This works great if you're just going from one animation to another, but not so for randomly picking an animation upon touching.
Thus far I have 2 animations for when you touch him but it's finicky for which one it'll pick. You can view what I've got done here: http://gamesalad.com/game/play/65221
Ps: For some reason even in Safari I can't get this thing to play properly, so I hope everyone else can.
Comments
To summarize, depending on the random number chosen (or a fixed order of numbers in an attribute) then: when random/attribute is such and such, run a particular Animation Behaviour sequence.
Hope that helps.
:-)
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
While I understand the value of having everything contained in one simple actor, the end result is that there's only ever going to be one character on the screen and nothing else. By breaking up the animation into multiple actors I can control how each of those behave properly and it boils down to simple "if" "then" statements.
Like I mentioned before, I'm not very good at programing right now and it seems like it would be rather hard for me to not only program it to play certain animations that lead into others but also switching between "allow touch" to "not allow touch" within those animations. By having separate actors I can designate from the start if touching will or will not do anything for each specific animation. Yes it ends up having a TON of actors in the end, but I'm comfortable with that for right now.
I guess what I'm looking for is what can I do for the initial "standing" animation to allow it to randomly spawn an actor at a random time? That's the piece of code that I don't know how to do.
The simple if/then statements would still all be simple in the one Actor. They'd all be in the one Rules list, although the list could turn out quite long though! But at least it'd be easier to tweak/amend/add to, etc.
Random spawning is no problem, but with respect, from your description and upload of what you're trying to do, you don't need spawning at all. A spawned actor, although it can be used as such, is hardly ever used to replace the actor that spawned it. Rather, it appears as an extra actor.
Anyhow, if I've not misunderstood completely, perhaps try the following?:
Create a scene (always safer) integer attribute called, say, SequChoice.
In your Rules, put when mouse or touch is down/pressed, change attribute SequChoice to random(1,5)... 5 being an example of the maximum number of sequences you have.
Then 5 rules follow: when attribute SequChoice = 1, then put the Animate Behaviour sequence you want, then etcetera up to 5.
That should work out OK, all in the 1 actor.
Hope it helps.
:-)
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
On top of that I've been able to add a timer. After 5 seconds of waiting, Janus will perform one of the 3 animations randomly on his own accord. And to keep things clean, I've been able to group everything together so I know what's part of the timer and what's part of the touch activation. I've updated the game online so you can all see how it looks now.
But now I've got a serious question. After letting him do his thing for a while, the game began to severely slow down until it eventually just stopped running. Is this a problem on my end? Does anyone else experience this? I'm worried that with all the animation the game might start to creep up in size and I want to keep this as simple as possible.
I can't view the game online for some reason even in Safari, so if someone could take a peek and check it out and give me some feedback on how it works, It would be very much appreciated.
http://gamesalad.com/game/play/65221
Thanks!
I wonder if it's worth temporarily deleting the Timer for the while, and see if it still slows down? That way, you'll know what causing the data jam; then perhaps it can be solved a different way.
Have you any other Rules other than the click + Timer ones? There could be something there upsetting it. (Oh, I've just written that)...or it could be a bug. Or...OK, I've run out of ors.... :-)
Seriously, I'd be interested in knowing if deleting the Timer solves the prob for the while.
;-)
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
I'm still really new at this so writing the code is still very challenging for me. If you have any suggestions or tips, It might help to explain it to me like I'm a 4 year old. lol. Although honestly I'm amazed I was able to pick up THIS much as it is! lol
The more I think about, the more I think the Timer is the problem; and I might know a "safer" way to get that aspect working. We wait to see...OK, off to download your gamefile and take a look.
:-)
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
As for the random animations after five seconds of no clicks, I've done a few tests but haven't yet managed to make it work successfully. I'll hopefully nail that one tomorrow some time for you.
In the meantime, i'll upload the revised so far for you to look at the Rules, to see what you think.
:-)
http://gamesalad.com/game/play/65294
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
Edit: I think I can get it to work... Just need to download the project.
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
chosenonestudios, I don't know what file I need to send and also gyroscope has already done some work on it (which I don't have yet) so I dunno what I should do. They seem to know exactly what needs to be done, it's just getting it to work for download so I can see it myself and fix it and stuff...
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
That's why I was breaking things up into actors because then I could say "this actor doesn't do anything if you touch it" or "this actor DOES do something if you touch it" whenever I wanted. It allowed me more control over the various elements because there are going to be instances where he'll start an animation, and if you touch him during that specific one, he'll play a different one, but if you don't he'll just go back to the first animation.
Does that make sense? I know it's convenient and logical to have them all in one actor. I have made some video games before and I know getting the actor to do everything you need them to do is vital to programing. But this is kinda a special case I think... I dunno...
I think at this point I prefer the multiple actor method. I just need to find a way to make it so it'll randomly play an animation on it's own if I don't touch it.
I really do appreciate the help though. Every step of the way I learn a bit more.
That has to be solvable somehow within the one actor though, I'm 99% certain. Although that doesn't help you if I can't think of anything at the moment...
I'll work on your file tomorrow now, (I mean today!) and see what I can come up with. Maybe another member might solve it first anyhow.
:-)
Edit: alternatively, stick with your spawning way (I thought there was a more straightforward way, but i see now that it doesn't immediately solve the click while animating problem; and we'll all have a bash at fixing the Timer. Sorry to mislead you (half of this is trying to think in the early hours of the morning; not good...)
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
There's gonna be several branching trees of animation choices down the road. Sometimes if you tap him at the right time during an animation he'll do a different action. Somehow I have to work out why the timer won't work for this. Whenever I have the timer running it goes very slow and usually crashes. Take the timer out and it's fine.
Now I'm new to this but could the cause of it be because of the checked box "run to completion"? or something along those lines?
"Clears throat, official voice": I'd like to take this opportunity to apologise to Adobson66 for my misguided advice concerning to not use spawns for each animation, telling him that it should all work nicely in one actor. Having spent several hours trying different things, I realise the folly of my way, as I couldn't get the "after 5 seconds, do its own thing" to work. I will whip myself immediately; thank you. :-)
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
http://gamesalad.com/game/play/37013
:-)
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
But if you want me to download your newest release I'll update with the after 5s thing working... Lemme know
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
That's what I had before and it worked for a while, but after a couple of animations it started to get boggled down and slow and eventually would crash. Like I mentioned before, is there possibly a checked box that I have that I shouldn't? Does having it set to "run to completion" checked make any difference? What does that box do anyway? When it deletes the actor and inserts the new one, shouldn't the original be reset back to 0, timer and all?