Page 2 of 7

Setting Animation for Actor

PostPosted: Mon Feb 24, 2014 8:56 pm
by Turon
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?

Re: Game Editor Favors Right over Left Continuation

PostPosted: Mon Feb 24, 2014 10:04 pm
by Hares
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 ... )

Re: Game Editor Favors Right over Left Continuation

PostPosted: Tue Feb 25, 2014 1:25 pm
by tvz
use Animation Finish event for that. in this event when a certain animation is finished, you can choose what should happen next

Re: Setting Animation for Actor

PostPosted: Thu Mar 06, 2014 8:28 pm
by Turon
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:

Re: Setting Animation for Actor

PostPosted: Thu Mar 13, 2014 9:00 pm
by Turon
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.

Re: Game Editor Favors Right over Left Continuation

PostPosted: Thu Mar 13, 2014 9:11 pm
by lcl
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.

Re: Setting Animation for Actor

PostPosted: Fri Mar 14, 2014 9:12 am
by Turon
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 ... )

Re: Setting Animation for Actor

PostPosted: Tue Mar 18, 2014 9:01 am
by Turon
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?

Re: Game Editor Favors Right over Left Continuation

PostPosted: Tue Mar 18, 2014 7:18 pm
by Hares
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 ...

Re: Setting Animation for Actor

PostPosted: Tue Mar 18, 2014 9:47 pm
by Turon
Okay I'll see wat I can do. :)

Re: Game Editor Favors Right over Left Continuation

PostPosted: Wed Mar 19, 2014 11:10 pm
by Hares
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.

Re: Game Editor Favors Right over Left Continuation

PostPosted: Wed Mar 19, 2014 11:23 pm
by Hares
@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

Re: Setting Animation for Actor

PostPosted: Thu Mar 20, 2014 8:15 am
by Turon
Good Idea thanks for the suggestion.

Re: Setting Animation for Actor

PostPosted: Thu Mar 20, 2014 5:56 pm
by Turon
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".

Re: Setting Animation for Actor

PostPosted: Thu Mar 20, 2014 6:19 pm
by MrJolteon
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".