Changing animation mid-jump

Non-platform specific questions.

Changing animation mid-jump

Postby arcreamer » Mon Jan 07, 2013 5:31 am

Hey so I'm trying to figure out how to make it so that my character does a certain animation when I press the jump key, but once he reaches his max height of elevation and begins to fall, he switches to a different animation. Is there a way to do that?
arcreamer
 
Posts: 398
Joined: Tue Jul 03, 2007 4:08 pm
Score: 9 Give a positive score

Re: Changing animation mid-jump

Postby skydereign » Mon Jan 07, 2013 5:34 am

I'd suggest using the state method. http://game-editor.com/State_Method
That way you can easily write code that can target individual actions the player does (like jumping). But, if you know the animindex values of jumping, you can use it in the same way. Essentially, an if statement checking if the animindex corresponds to a jump animation, and checking if yvelocity>0 (falling) change the animation to your fall animation. That way the if will make sure you only change the animation when the player is jumping, and begins to fall.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Changing animation mid-jump

Postby arcreamer » Mon Jan 07, 2013 6:13 am

Trying to understand what you linked, but I'm not gettin it. lol. I tried the if yvelocity = 0; it would switch the animation, but I already had a draw actor script with yevolicty=yvelocity+1; for gravity, so it didnt work. wouldnt let me jump
arcreamer
 
Posts: 398
Joined: Tue Jul 03, 2007 4:08 pm
Score: 9 Give a positive score

Re: Changing animation mid-jump

Postby skydereign » Mon Jan 07, 2013 6:18 am

Not yvelocity=0, that would set yvelocity equal to 0. You can use inequalities in if statements, so you can check if yvelocity is positive. You know that if the actor is jumping, and they have a positive yvelocity, that means they are falling.
Code: Select all
if(animindex==4 && yvelocity>0) // assuming 4 is the jump animation
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Changing animation mid-jump

Postby arcreamer » Mon Jan 07, 2013 6:24 am

well I plugged in what you wrote, along with the change animation thing, but now it just looks like my character is havin a seizure.. and doesnt change the animation at all when I jump

Code: Select all
if(animindex==4 && yvelocity>0);

{
    ChangeAnimation("Event Actor", "Standby_1", FORWARD);
}
arcreamer
 
Posts: 398
Joined: Tue Jul 03, 2007 4:08 pm
Score: 9 Give a positive score

Re: Changing animation mid-jump

Postby skydereign » Mon Jan 07, 2013 6:27 am

That's because you are using if incorrectly. You are ending the if prematurely, so that code with the {} always runs. Remove the semicolon after the if, and it won't do that.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Changing animation mid-jump

Postby arcreamer » Mon Jan 07, 2013 6:29 am

Gotcha. Alright so I removed the semicolon, now its seems to have fixed the seizure problem, but hes not changing his animation when hes falling
arcreamer
 
Posts: 398
Joined: Tue Jul 03, 2007 4:08 pm
Score: 9 Give a positive score

Re: Changing animation mid-jump

Postby skydereign » Mon Jan 07, 2013 6:33 am

Well, as the comment in the code I posted says, that would only work if animindex 4 is your jump animation. You can tell the animindex values for animations by looking at the order they appear when you go to change animation (starting with 0). So if you still can't get it after this post, type up the list of animations your actor has in the same order as gE shows you.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Changing animation mid-jump

Postby arcreamer » Mon Jan 07, 2013 6:34 am

Ooh, I had it as my 4th, didnt know it started with 0. Its working now, thanks man
arcreamer
 
Posts: 398
Joined: Tue Jul 03, 2007 4:08 pm
Score: 9 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest

cron