Setting Animation for Actor(Experimenting with State Method)

Non-platform specific questions.

Re: Setting Animation for Actor

Postby Turon » Thu Mar 27, 2014 10:51 pm

Okay I've just revized the code! it will revert the players animation to a standing posture upon collision with ground in the action of holding down the jump key,
however it will not stop the player from jumping over & over again with the action of holding down the jump key. Other bugs include the inability to pass onto a walking animations after the event.
Code: Select all
char *key = GetKeyState(); //Get entire keyboard state
if(key[KEY_x] == 1)//TEST IF X IS PRESSED
{
jump=1;
}
if (animindex==5)
//PlayJumpLeft is animindex 5
{
    ChangeAnimation("Event Actor", "PlayerStillLeft", FORWARD);
}
if (animindex==6)
//PlayerJump is animindex 6
{
    ChangeAnimation("Event Actor", "PlayerStillRight", FORWARD);
}
Turon
 
Posts: 862
Joined: Sun Jan 24, 2010 5:23 pm
Score: 32 Give a positive score

Re: Setting Animation for Actor

Postby lcl » Fri Mar 28, 2014 9:35 am

Think about your code.
Look at it and think for answers for these questions:

1. When to code is activated?
2. When the variable jump gets set to 1 - when are you allowing the character to jump again?
3. When shoukd the character be allowed to jump again?
4. When does the animation changing occur? (When is the code activated?)

There is two things that need fixing, and they cause the problems you mentioned. Thinking about what your code actually does and when it does it, helps you to see what is wrong.
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 » Mon Mar 31, 2014 9:22 am

Hang on I'm just thinking about it now, I'll report when something happens.
Turon
 
Posts: 862
Joined: Sun Jan 24, 2010 5:23 pm
Score: 32 Give a positive score

Re: Setting Animation for Actor

Postby Turon » Sun Apr 06, 2014 9:07 pm

So if I need to start understanding the code more lets start with the != stuff in the code,
I know that "!=" means not equal to, but why can't it just be as easy as changeing number values?
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 Apr 08, 2014 1:52 pm

I have figured out the != part now I just need to figure out the reason why the player will not return to a walking posture after the event takes place,
I have figured that "jump == 1" actually means that you aren't jumping. hmmm.......... don't worry I'll work it out eventually :lol: !
Turon
 
Posts: 862
Joined: Sun Jan 24, 2010 5:23 pm
Score: 32 Give a positive score

Re: Setting Animation for Actor

Postby lcl » Tue Apr 08, 2014 3:40 pm

Could you post your current version of the ged with the data and I'll see what's wrong and then give you instructions for fixing it?
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 » Tue Apr 08, 2014 6:38 pm

Okay Here the ged is... why do I have an odd feeling that the answer is right under my big nose?
Attachments
Statik's World (3).zip
(80.71 KiB) Downloaded 134 times
Turon
 
Posts: 862
Joined: Sun Jan 24, 2010 5:23 pm
Score: 32 Give a positive score

Re: Setting Animation for Actor

Postby Turon » Mon Apr 14, 2014 9:36 pm

Is it something to do with the jump variable? Whatever it is something is forbidding the left and right walking.
Or maybe for some reason the left and right walking is no longer being triggered?
Turon
 
Posts: 862
Joined: Sun Jan 24, 2010 5:23 pm
Score: 32 Give a positive score

Re: Setting Animation for Actor

Postby lcl » Mon Apr 14, 2014 11:04 pm

Oh, sorry, I forgot to answer you..
The reason why it doesn't allow the walking animations to play is that you still didn't check if the jump key is not pressed, in other words, if
KEY_x == 0. You checked if it was pressed and that caused him to not change his animation back to walking.

However, making it check if the key is not pressed doesn't still solve all problems.

The easiest fix is to just leave the whole check away.
Sure, this makes the actor jump immediately when touching ground if you're still holding the jump button, and that is another problem. That problem can be solved by setting the repeat of the x key down event to disabled, but then another problem appears, in the form of the character doing funny movement when you land from a jump and keep holding x down. And that can be solved by doing this:

- Remove the key[KEY_x]!=1 conditions from the 5th and 7th if's in the draw actor code
- Replace the key[KEY_x] == 1 from the 9th and 12th if's in the draw actor code with jump==0

The reason why this is so complicated is because of how you manage your movement. Having it all based on what keys are pressed and what aren't makes it very difficult to follow what is happening in the code when playing. I'd suggest you to learn the state method (search "state method" on the game editor wiki).
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 » Tue Apr 15, 2014 7:13 pm

Forgive me for my ignorance but what is this state method everyone's talking about? Is that the reason I suck so hard with Programming? :? :oops:
Turon
 
Posts: 862
Joined: Sun Jan 24, 2010 5:23 pm
Score: 32 Give a positive score

Re: Setting Animation for Actor

Postby lcl » Tue Apr 15, 2014 7:46 pm

State method is one method of handling character movement and animation changing.
As I told you, search the Game Editor wiki with the words "State method" for more information.

And you don't actually possibly suck at coding, it's just that the system you use for movement currently makes it pretty much impossible
to have everything working as you want, because every piece of code interferes with the other pieces. State method can help you say goodbye to that problem.
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 » Thu Apr 17, 2014 2:56 pm

Thank. I'm working on learning state method right now.
Turon
 
Posts: 862
Joined: Sun Jan 24, 2010 5:23 pm
Score: 32 Give a positive score

Re: Setting Animation for Actor RENEWED TOPIC

Postby Turon » Tue May 06, 2014 7:02 pm

I have compleatly changed the movement system based on the UnproPro's How to Make a Game Tutorials. The Jumping animation play flawlessly,
The Shooting animation seems to be the problem now. Also I am reworking the graphical style.
Attachments
Statik's World.zip
(24.19 KiB) Downloaded 127 times
Last edited by Turon on Thu May 08, 2014 3:39 pm, 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 RENEWED TOPIC

Postby Turon » Mon May 12, 2014 7:46 am

The shooting is a little funny now I don't really know what to do since the new movement engine is so different. :?
So where do I go from here? I myself have tried I busted my brain trying to figure it out.
It is clear we need more than one brain to figure this problem out.
Turon
 
Posts: 862
Joined: Sun Jan 24, 2010 5:23 pm
Score: 32 Give a positive score

Re: Setting Animation for Actor RENEWED TOPIC

Postby Turon » Wed May 14, 2014 9:42 am

Hang on I think I'm getting somewhere I'll report back if there is any trouble.
Turon
 
Posts: 862
Joined: Sun Jan 24, 2010 5:23 pm
Score: 32 Give a positive score

PreviousNext

Return to General

Who is online

Users browsing this forum: No registered users and 1 guest