Setting Animation for Actor(Experimenting with State Method)

Non-platform specific questions.

Setting Animation for Actor

Postby Turon » Mon Feb 24, 2014 8:56 pm

The System works and does basically what I was expecting it to, However the Jump no longer has a key up event so that wen I lift the key up he stays in a jump posture.
What is with those "!" marks in the code?
Last edited by Turon on Thu Mar 20, 2014 8:38 am, edited 1 time in total.
Turon
 
Posts: 862
Joined: Sun Jan 24, 2010 5:23 pm
Score: 32 Give a positive score

Re: Game Editor Favors Right over Left Continuation

Postby Hares » Mon Feb 24, 2014 10:04 pm

Turon wrote:What is with those "!" marks in the code?

if (a == b) means if a equals b
if (a != b) means if a does not equal b
Turon wrote:However the Jump no longer has a key up event so that wen I lift the key up he stays in a jump posture.

To start the jump you press the jump button.
Then while the player is jumping the jump animation should be active.
Therefore it should not be ended by a key up event, because then your jump animation only plays while you are pushing the jump button.

If you want to change the jump animation to the standing animation, you should do that when the player lands.
So either you put it in the collision with top of land.
Or you put it in the draw actor event, and you control it with the canjump variable.
(if animation == jumping and canjump == 1, change animation to ... )
User avatar
Hares
 
Posts: 105
Joined: Fri Dec 20, 2013 8:39 pm
Location: Belgium
Score: 14 Give a positive score

Re: Game Editor Favors Right over Left Continuation

Postby tvz » Tue Feb 25, 2014 1:25 pm

use Animation Finish event for that. in this event when a certain animation is finished, you can choose what should happen next
User avatar
tvz
 
Posts: 98
Joined: Sun Mar 10, 2013 7:13 am
Location: Your PC screen
Score: 3 Give a positive score

Re: Setting Animation for Actor

Postby Turon » Thu Mar 06, 2014 8:28 pm

Tvs I'm sorry but there are some problems with your idea... you see I made my jump animation 2 frames and the player will revert to a standing posture within midair and even if I made it 3 the hight to which the player fall will not be consistent with the time it takes for an animation to finish all the time so ummmm....

and Harres you got me... You know I'm an overgrown newbie and I don't understand things as well as I shud :oops:..... :lol:
Last edited by Turon on Thu Mar 20, 2014 8:38 am, edited 1 time in total.
Turon
 
Posts: 862
Joined: Sun Jan 24, 2010 5:23 pm
Score: 32 Give a positive score

Re: Setting Animation for Actor

Postby Turon » Thu Mar 13, 2014 9:00 pm

OK OK I braved it! but it doesnt work (I just pasted it at the bottom of the existing code) and worst of all its a monster code!
Code: Select all
if(ChangeAnimation("Event Actor", "PlayerJumpLeft", NO_CHANGE); && (ChangeAnimation("Event Actor", "PlayerJumpRight", NO_CHANGE); == jump && canjump == 1, if (dir==1) (ChangeAnimation("Event Actor", "PlayerStillLeft", NO_CHANGE) if (dir==2) (ChangeAnimation("Event Actor", "PlayerStillRight", NO_CHANGE);                                                                       

all of that code is in a strait line and a VERY long line.
Last edited by Turon on Thu Mar 20, 2014 8:39 am, edited 1 time in total.
Turon
 
Posts: 862
Joined: Sun Jan 24, 2010 5:23 pm
Score: 32 Give a positive score

Re: Game Editor Favors Right over Left Continuation

Postby lcl » Thu Mar 13, 2014 9:11 pm

Turon wrote:OK OK I braved it! but it doesnt work (I just pasted it at the bottom of the existing code) and worst of all its a monster code!
Code: Select all
if(ChangeAnimation("Event Actor", "PlayerJumpLeft", NO_CHANGE); && (ChangeAnimation("Event Actor", "PlayerJumpRight", NO_CHANGE); == jump && canjump == 1, if (dir==1) (ChangeAnimation("Event Actor", "PlayerStillLeft", NO_CHANGE) if (dir==2) (ChangeAnimation("Event Actor", "PlayerStillRight", NO_CHANGE);                                                                       

all of that code is in a strait line and a VERY long line.

I see a lot of errors in that code. First of all, what are you trying with checking if ChangeAnimation is equal to something?
ChangeAnimation returns 1 if the animation changing succeeded, otherwise it returns 0. But I've never seen it not succeed, so it will always return 1.
Also, no matter what the function is, you are not supposed to have the semicolon ";" in the if statement.
Also, why is there a comma in the if statement (just there before the if (dir == 1)).
One more thing is that you actually only have a condition there, not any action to do if the condition is true.
And you don't have a matching amount of "("s and ")"s .

I guess what you are trying to do with that checking of ChangeAnimation is to actually check if the actor currently has certain animation, and for that you should use getAnimIndex check vs the actors animindex variable's value.
Also, you don't have to have it one a single line.

You say that you just pasted the code to the bottom line of the existing code. Where did you get this code? Also, you should never just paste some code from somewhere, it won't ever work.
You have to first figure out what the code is doing.
User avatar
lcl
 
Posts: 2339
Joined: Thu Mar 25, 2010 5:55 pm
Location: Finland
Score: 276 Give a positive score

Re: Setting Animation for Actor

Postby Turon » Fri Mar 14, 2014 9:12 am

Apon collision with the ground the player will remain in a jump posture as apposed to changing back to a left or right standing posture. I'm trying to return the player to a standing posture once the player collides with the ground.
lcl Wrote:
You say that you just pasted the code to the bottom line of the existing code. Where did you get this code? Also, you should never just paste some code from somewhere, it won't ever work.
You have to first figure out what the code is doing.

I made is based on the last post of hares's and I typed it in a script editor prior to pasting.
Hares Wrote:
(if animation == jumping and canjump == 1, change animation to ... )
Last edited by Turon on Thu Mar 20, 2014 8:42 am, edited 1 time in total.
Turon
 
Posts: 862
Joined: Sun Jan 24, 2010 5:23 pm
Score: 32 Give a positive score

Re: Setting Animation for Actor

Postby Turon » Tue Mar 18, 2014 9:01 am

On the contrary even if I got that long code to work it would be to cumbersome for a simple gameplay mechanic,
Do you have any ideas on how to get a nice efficient compact code to return the player to a standing possition apon colliding back on the ground?
Last edited by Turon on Thu Mar 20, 2014 8:43 am, edited 1 time in total.
Turon
 
Posts: 862
Joined: Sun Jan 24, 2010 5:23 pm
Score: 32 Give a positive score

Re: Game Editor Favors Right over Left Continuation

Postby Hares » Tue Mar 18, 2014 7:18 pm

Hares wrote:(if animation == jumping and canjump == 1, change animation to ... )

This is not something you should just translate into code ... That won't work.
What I tried to tell you was that I see two options for doing this.

The first one is:
In a collision event between the player and the ground, that is set not to repeat, you put some code that checks if the player is in the jump animation. You can do this if you know the animindex.
If yes, change it to the default standing animation.
And while doing this you should check if you are facing left, or facing right ... so you can set the standing animation to face left or right.

The second option is:
In the draw actor event add some code that checks if the current animation is the jump animation. You can do this if you know the animindex of the jump animation.
If yes, check if the canjump variable is set to the value that allows you to jump again.
If so, that means you are (or were) touching the ground.
Then change the animation to the standing animation.
Make shure to this for facing left, and for facing right.

For the moment I don't have much time. If you can't figure it out yourself, or you don't get help from someone else, I can try to help you later ...
User avatar
Hares
 
Posts: 105
Joined: Fri Dec 20, 2013 8:39 pm
Location: Belgium
Score: 14 Give a positive score

Re: Setting Animation for Actor

Postby Turon » Tue Mar 18, 2014 9:47 pm

Okay I'll see wat I can do. :)
Last edited by Turon on Thu Mar 20, 2014 8:44 am, edited 1 time in total.
Turon
 
Posts: 862
Joined: Sun Jan 24, 2010 5:23 pm
Score: 32 Give a positive score

Re: Game Editor Favors Right over Left Continuation

Postby Hares » Wed Mar 19, 2014 11:10 pm

I just had some time, and I got it to work the way you want it to.

I went for the first option

What I did:
In the collison (any side of Ground) I removed the
Code: Select all
jump=1


I made a new collision event
collision (top side of Ground) -> repeat no
Code: Select all
jump=1;
if (animindex==5)
//PlayerJumpLeft is animindex 5
{
    ChangeAnimation("Event Actor", "PlayerStillLeft", FORWARD);
}
if (animindex==6)
//PlayerJumpRight is animindex 6
{
    ChangeAnimation("Event Actor", "PlayerStillRight", FORWARD);
}

This got the animation to change from jumping animation to standing animation on contact with the ground.
However, when you jump, and then you shoot, the animation wil stay on the shooting animation.

To fix this I added the following code to the player draw actor event.
I added this code after the "char* key = GetKeyState();" and before the first if statement:
Code: Select all
if (yvelocity!=0 && jump!=1)
// IF MOVING VERTICAL WHILE NOT BEING ABLE TO JUMP
{
    if (dir==1)
    {
        ChangeAnimation("Event Actor", "PlayerJumpLeft", NO_CHANGE);
    }
    if (dir==2)
    {
        ChangeAnimation("Event Actor", "PlayerJumpRight", NO_CHANGE);
    }
}

This code checks if you are moving vertical, and if you are jumping. If so it changes the animation to jump animation facing left or facing right.

The only thing that is not right now is that the first time you jump the animation doesn't change to jumping animation.
To fix this I added a create actor event for the player in which I put this code:
Code: Select all
jump=1;


Now it works :D
Here is the modified ged file.
Attachments
Statik's World-Hares2.ged
Fixed the jumping animation on landing on the ground
(8.64 KiB) Downloaded 143 times
User avatar
Hares
 
Posts: 105
Joined: Fri Dec 20, 2013 8:39 pm
Location: Belgium
Score: 14 Give a positive score

Re: Game Editor Favors Right over Left Continuation

Postby Hares » Wed Mar 19, 2014 11:23 pm

@Turon
By the way, I think you should change the title of this tread. Because it is not Game Editor that favors right over left continuation. :wink:
The title could be:
Setting animation for actor
User avatar
Hares
 
Posts: 105
Joined: Fri Dec 20, 2013 8:39 pm
Location: Belgium
Score: 14 Give a positive score

Re: Setting Animation for Actor

Postby Turon » Thu Mar 20, 2014 8:15 am

Good Idea thanks for the suggestion.
Last edited by Turon on Fri Mar 21, 2014 4:48 pm, edited 2 times in total.
Turon
 
Posts: 862
Joined: Sun Jan 24, 2010 5:23 pm
Score: 32 Give a positive score

Re: Setting Animation for Actor

Postby Turon » Thu Mar 20, 2014 5:56 pm

It Works great thanks man :mrgreen:. I still don't know quite how the animindex works.
& I'm sorry say that I still do quite understand the "!" In the code are for, I'd think that 0 stands for "off" & 1 stands for "on".
Turon
 
Posts: 862
Joined: Sun Jan 24, 2010 5:23 pm
Score: 32 Give a positive score

Re: Setting Animation for Actor

Postby MrJolteon » Thu Mar 20, 2014 6:19 pm

Turon wrote:& I'm sorry say that I still do quite understand the "!" In the code are for, I'd think that 0 stands for "off" & 1 stands for "on".

Code: Select all
!=
means "not equal to". So when it says
Code: Select all
if (yvelocity!=0 && jump!=1)

it means "if yvelocity is not equal to 0 and jump is not equal to 1".
Join us on Discord!
Game Editor 2
These are the best ways to reach me these days


Your local Community Janitor, always lurking in the shadows...
User avatar
MrJolteon
 
Posts: 2326
Joined: Sat Aug 09, 2008 3:25 pm
Location: Stranded under endless sky
Score: 105 Give a positive score

PreviousNext

Return to General

Who is online

Users browsing this forum: No registered users and 1 guest