Page 1 of 1

Problems with changing an animation

PostPosted: Thu Mar 13, 2008 11:25 am
by msv83
The character in the game I'm making changes animation depending on action (run forward, run backward, stop right, stop left, jump right, jump left, shoot right, shoot left), but I have a problem making the jump and shoot animations stop.

When the character is running forward, and I press the space bar (which is the "jump" button), the character changes into the jump animation, but I can't make it change back to the normal running-animation when it hits the ground. So if I, after having pressed the jump button, doesn't release the forward button, the character keeps going forward, but keeps the jump animation...

Sorry if I'm making this a bit confusing...

But what I'd like to do, is make the character change back to the forward (or backward) animation when it hits the ground again. Or when it's about to land, it doesn't really matter...as long as it just keep running normal when it's back on the ground. I tried some animation finish and timers, but none of them worked so I guess that's either not the way I can do it, or I did it wrong.

Any ideas? :)

Re: Problems with changing an animation

PostPosted: Thu Mar 13, 2008 1:32 pm
by edh
What if you store the previous animation, and when you collide or end your jump animation, restore the previous animation?

Actually, that may not even be right, maybe your events are a little messed up?

You've got key-down + collide with the ground for running whichever way.
If you're not colliding, you're jumping, right?

Re: Problems with changing an animation

PostPosted: Thu Mar 13, 2008 5:12 pm
by jlorinser
Hi MSV83,

Have you tried this:

If the character's animindex value is equal to your "jump left" or "jump right" animation when colliding back with the ground (after the jump), change the animation to running left or right depending on the direction it jumped (the animindex of the jump).

Hope it helps!

Re: Problems with changing an animation

PostPosted: Thu Mar 13, 2008 8:30 pm
by msv83
Thanks for trying to help me out, both of you :)

I'm probably a bit too much of a newbie in all this to really understand the suggestions you are giving me... :oops:

The collisions I have for the ground, are these:

collision - top side of ground - script editor - "canjump=1;"

physical response - any side of ground - the settings 1, 1, 0 and 1...

Re: Problems with changing an animation

PostPosted: Thu Mar 13, 2008 10:41 pm
by msv83
There are some other topics regarding the same problem I've got (none of them seems to have been solved though), and they might explain it a bit better than I do...

http://game-editor.com/forum/viewtopic.php?f=4&t=1772
http://game-editor.com/forum/viewtopic.php?f=1&t=2010

Re: Problems with changing an animation

PostPosted: Fri Mar 14, 2008 6:13 pm
by edh
I'm still thinking about this one... :|

Re: Problems with changing an animation

PostPosted: Sat Mar 15, 2008 8:13 am
by j2graves
aren't there animation finish events?

Re: Problems with changing an animation

PostPosted: Sat Mar 15, 2008 9:27 am
by edh
@j2graves, yes there are. It's a good idea. I was going to suggest that too, but you don't actually want an animation finish, I think - I could be wrong. I think you want to change the animation on collision because you could collide before your animation finishes the jump action. And you wouldn't want the actor to switch to running in mid air, either.

Re: Problems with changing an animation

PostPosted: Sat Mar 15, 2008 5:58 pm
by msv83
Hm...seems to be a hard one, this one... :|

I've been thinking about key up event, but that doesn't work very good since the character moves both to the left and to the right, and there's two different jump animations...

Re: Problems with changing an animation

PostPosted: Sat Mar 15, 2008 10:13 pm
by DilloDude
What you need to do is have variables with the current state: wether you are walking or not, which direction you are facing, and wether you are in the air or on the ground (you probably already have this). This makes a lot of things simpler. Then in draw actor, you just check those variables to figure out which animation should be playing, and change it if necessary.

Re: Problems with changing an animation

PostPosted: Sun Mar 16, 2008 3:02 pm
by msv83
Thanks! Just one thing...how should I do this? I'm afraid I'm still very inexperienced and don't really know how to do exactly that step by step... :oops: