Animation Problems, canceling movement

Get help using Construct 2

Post » Thu Aug 07, 2014 12:06 am

Hi! I just got started with Constructor 2 and I've run into a little problem.

I have a character that I move with A and D. When I press one of those buttons my character will start moving along with an animation (named 'Walking'). This works fine, however:

What I want to do is that when you release the move buttons, the character will finish it's move animation and then stop rather than stopping mid-animation. My problem though is that the character continues to move forever even though I've (I think) told it to stop moving after finishing it's animation. It's much easier to show what I mean by posting the event sheet, please see attachment.

EDIT: Sorry, I meant the character continues to ANIMATE forever, not move. My mistake!

EDIT SOLUTION: It seems that I got it to work, but not by using 'onFinish'.
Here's what I did:
At the keyboard A&D != check, I added 'isAnimationPlaying'
And then I replaced 'onAnimationFinished' with 'compareFrame' to check if it's the last frame. If it is, then I stop the animation.

Maybe I should've tried that before posting here, didn't think about it then though. Now we know at least!

Help is greatly appreciated. :)
You do not have the required permissions to view the files attached to this post.
B
20
S
8
G
4
Posts: 195
Reputation: 3,555

Post » Thu Aug 07, 2014 12:44 am

I'm looking at it. can u post a capx?

Your write up is a little confusing.

Can't really see everything, like is the animation set loop?

If I get it, you just switch the animation instead of trying to stop it. Make a duplicate animation that is not set to loop and is triggered instead.
Image
B
75
S
23
G
3
Posts: 673
Reputation: 9,283

Post » Thu Aug 07, 2014 1:36 am

Sure, attached the file. :)

I got it to work somewhat but I still have one problem. Now, when you release the button slightly before the animation ends, the character will glide on the floor for the duration of the movement. Can I somehow do a check to see if he's still moving when the animation has ended to squeeze in another loop to smooth things out?
You do not have the required permissions to view the files attached to this post.
B
20
S
8
G
4
Posts: 195
Reputation: 3,555

Post » Thu Aug 07, 2014 11:00 am

So I digged a bit deeper into the manual and it seems that looped animations don't finish. That's why onAnimationFinish won't work. So, is there a way to toggle off loops for animations mid-game? Because I have an idea of how to get it to work if I can do that somehow.

EDIT: So I found a way to make it work. I played around with the idea of additional animations like you mentioned and I found a solution:

What I did was that I created 2 additional animations, one for when the player release the move keys when the character stands mid-walk on her right foot and one for when she stands mid-walk on her left. What I did then was I compared the current frame of the walk animation for when the key released (for example, if I release the move key on frame 4, which is the right foot) then I'd play one of the additional animations that start on corrisponding foot, and vice versa).

So I finally got it work like I want it to. Problem solved.
B
20
S
8
G
4
Posts: 195
Reputation: 3,555


Return to How do I....?

Who is online

Users browsing this forum: Christmas, Lancifer and 22 guests