Simple animation problem driving me nuts

0 favourites
  • 8 posts
From the Asset Store
Basic Rounded Vector Geometry Player Design with Glow for 3 player games
  • Hey. I have a question. I'm not sure if I've asked this before... but I am LOSING MY MIND here.

    Basically, I'm trying to do something as basic as make a character attack.

    I've tried tutorials all over the place, but most tutorials feature a block character and a separate object.

    But my character is just one object, and I'm trying to get it to enter an attack animation.

    Now, this is what I'm doing:

    Basically, I'm doing so that when I press "R", I get my character to attack.

    I haven't reached the point where it attacks because I'm already struggling in getting ANY animation I call upon, (that apparently requires a variable? such as direction where the character is facing, or the variable that detects if it's attacking... this is just a wild guess), to run more than just THE FIRST FRAME.

    Instances that do not require a variable such as running (although again... direction variable is used, and I have no problem here) jumping, and falling, is perfectly fine.

    But animating attacks is a near impossible feat. And again, I've searched tutorials, but they all use pretty basic 1-frame sprites and animations, so it serves no purpose to me.

    And I'm not even mentioning the one where a character of mine ran and shoot in Megaman fashion, where I had to replace the "run and shoot" animation over the "run" animation, and it would only load the first frame..

    Please... what am I doing wrong? Why is it SO hard to load animations?

    tl;dr: When I press attack, character just loads a "sword at ready" frame, and goes back to his neutral animation, and doesn't execute the whole attack animation.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Looking at your events, I'm guessing you are not giving enough time for the animation to play. So it probably starts, but then gets set back to what it was. You could try setting it so when the animation ends (I know there is a condition for this, just don't know it off by heart), set the default animation again.

  • I have 2 main comments. If thats ok.

    One.

    IF you use the same object for showing of the animation AND for reading out its platform expressions, THEN i can not make any conclusion without seeing the animation frames. If the animation frames differ in size, if the origins are not on the same relative place, if the collision boxes are not the same, then the platforms expressions are not reliable. It will trigger as 'falling' when standing on the floor, by instance. It will be constantly be in a state of 'landing', even when in the floor, and the platforms 'push out of solids routine' will work overtime. (eating performance like a troll)

    Two.

    The logic of you events.

    If you look at any tutorial ( https://www.google.be/search?q=scirra+t ... animations ) regarding animations and platformers, they all use 'mirror'. You seem to have a animation for 'left' and 'right' which makes things to complicated. Just use 'mirror'.

    That use of 'wait' i can not recommencement at all.

    Lets run trough your event tick by tick. Starting at the moment 'R' is pressed. And assuming that it is not jumping. 'P1direction does not matter.

    Tick 1 ('R' is pressed)

    KondarAttack = 1

    That makes event 91 true.

    So it plays the animation from start.

    Wait 0.1 seconds is at a 60 FPS like 6 ticks.

    So, KondarAttack gets set to zero in about 6 ticks.

    Tick 2

    KondarAttack = still 1

    That makes event 91 true.

    So it plays the animation AGAIN from start. (start = frame zero)

    The wait has 5 ticks to go.

    Tick 3

    KondarAttack = still 1

    That makes event 91 true.

    So it plays the animation AGAIN from start. (start = frame zero)

    The wait has 4 ticks to go.

    Tick 4

    KondarAttack = still 1

    That makes event 91 true.

    So it plays the animation AGAIN from start. (start = frame zero)

    The wait has 3 ticks to go.

    Tick 5

    KondarAttack = still 1

    That makes event 91 true.

    So it plays the animation AGAIN from start. (start = frame zero)

    The wait has 2 ticks to go.

    Tick 6

    KondarAttack = still 1

    That makes event 91 true.

    So it plays the animation AGAIN from start. (start = frame zero)

    The wait has 1 ticks to go.

    Tick 7

    KondarAttack = still 1

    That makes event 91 true.

    So it plays the animation AGAIN from start. (start = frame zero)

    The wait has 0 ticks to go.

    Tick 7

    Finaly KondarAttack = 0

    That makes event 91 untrue.

    So there is no animation started

    It might work if you lose the "wait' and if you lose the 'start animation from beginning'. But you can not expand this logic anymore. So pwetty plz, look at the tutorials that handle platform and animations. (i linked you a lot of them)

    Have also this in mind. A new animation gets played when 1/ the new animation is not all ready playing or 2/ the current playing is the same as then new animation, but is at its last frame. So never loop animations if you plan to change them.

    My little 2 pennys.

  • You have the animation set to attack and then immediately reset to beginning of animation again.

    Remove that set to beginning of animation as it will always start at the beginning of an animation unless you tell it otherwise.

    You are using a variable P1 to determine the direction the player is facing which is good but where are you setting that variable?

    That could be the reason the attack animation is not playing so I would have to see your other control events that sets that variable.

  • what happens in your code is this

    1 you have what lamar said, "You have the animation set to attack and then immediately reset to beginning of animation again."

    2 the condition is KS =1 acts like a everytick loop, which means is continuously playing that event (everyframe = 0.01 seconds or 60 times /1 second / C2 system always try to run at 60 fps and its direct influenced by the "lag" caused by CPU intesity) when the conditions are met,

    drag the conditions you have as sub-conditions under the R pressed.

    (conditions i mean kondarattack-1and is not jumping same applies to the other one.)

    3 reading the above, you dont give enough time for animations to be visually visibile. while they are playing, but they are to fast.

  • Thank you all for the answers.

    I've read them all, and now I'll go see where I went wrong.

    Curious thing is, the way I handled it did work before in another project, only difference is, the direction variable was not used then, and it worked.

    I want to explain some of my decisions here. Even though I've been using C2 for a while, I'm still so very new, so please bear with me.

    Anyway:

    #1 Direction variable.

    Maybe I'm overcomplicating things, but the logic behind my decision, was that because the character in this example is using a sword, I want him to keep it in the same hand no matter what direction he's facing.

    Thus why I didn't settle for a [Set Mirror] event, but I still need to have a variable to tell me where this character is facing.

    I've set this variable whenever I press "Q" and "E" which simulate Left and Right.

    Am I wrong to assume that the Player (Platform) Object won't automatically Set Mirror itself when I Simulate Keyboard: LEFT? Because if I am, then I could totally ditch the Direction variable, unless there was another way...?

    I think I used to have problems when making a player object jump and stuff without these variables.

    #2 Way I'm handling the player character:

    My player character consists of an invisible sprite (so it's ... collision box, for a lack of the appropiate word, is a rectangle, 128 wide, 255 high). This is an object called, say... P1.

    And I've pinned the character's graphic, approximately same size, but not a solid object, to the P1.

    I've had a lot of collision issues in the past, when instead of havng an invisible player object with a pinned character object, I set a player object with its appropiate graphic (and collision boxes), so I wanted to save myself from some problems along the way.

    (If you must know, these are some of the problems I remember having, when the player object had its own graphic and collissions).

    Having only a full jump whenever I press jump.

    If I hold on to the jump button, it keeps jumping once it touches the ground.

    Collision glitches causing the character to fall when he's standing or walking, thus messing up the animation)

    #3 The use of Wait.

    Ok, normally, if animations had worked for me, I would've probably gone with [wait until animation ends], but since I only get 1st frame out of my attack animations, I went with [Wait], to generate a (forced) sense of delay when a character hits. This character is supposed to be on the heavy-hitter side, so I gave him a bit more wait time than the others (but still, they use a [wait] event as well).

    -----

    Again, thank you all so much for your replies, I will get on on this, and see how it goes. I'll go back to watch the tutorials again to see where I went wrong.

  • UPDATE:

    Ok, so thanks to the help all of you provided (again, thanks so very much) I was not only able to fix my animation issues, or at least, I've only directly applied the changes to one character, and then remade the rest practically from scratch, but I noticed what I was doing wrong.

    It turns out I was using some pretty "hard" conditions to move characters around.

    So, instead of using "On Moved", I kept using "If Platform is Moving", or instead of "On Jump", I used "If Platform is in the air".

    These things completely blocked any attempt from me to execute any animation properly...

    So, thank you! This was much help!

    ----

    Now... could I ask one tiny more thing?

    I decided to settle with just MIRRORing the graphic of the only character whom I wanted to have a separate graphic when he's facing left and when he's facing right.

    But if any of you has the time, could you explain to me how you would do it? I mean, handling a character WITHOUT the SET MIRROR event so that he has small changes when he's looking at different directions?

    I'd really appreciate that, but it's not SUPER essential. It's just that it's killing me that I can't figure it out.

    I had managed something really close, but if I make him move to the right, and then move to the left (if I accidentally press the other way fast enough) the character will strafe backwards. And that will mess up the rest of the animations, such as jumping, etc.

    Anyway, consider it a sidequest, perhaps. But once again, the main problem has been resolved, you have my thanks!

  • UPDATE:

    Ok, so thanks to the help all of you provided (again, thanks so very much) I was not only able to fix my animation issues, or at least, I've only directly applied the changes to one character, and then remade the rest practically from scratch, but I noticed what I was doing wrong.

    It turns out I was using some pretty "hard" conditions to move characters around.

    So, instead of using "On Moved", I kept using "If Platform is Moving", or instead of "On Jump", I used "If Platform is in the air".

    These things completely blocked any attempt from me to execute any animation properly...

    So, thank you! This was much help!

    ----

    Now... could I ask one tiny more thing?

    I decided to settle with just MIRRORing the graphic of the only character whom I wanted to have a separate graphic when he's facing left and when he's facing right.

    But if any of you has the time, could you explain to me how you would do it? I mean, handling a character WITHOUT the SET MIRROR event so that he has small changes when he's looking at different directions?

    I'd really appreciate that, but it's not SUPER essential. It's just that it's killing me that I can't figure it out.

    I had managed something really close, but if I make him move to the right, and then move to the left (if I accidentally press the other way fast enough) the character will strafe backwards. And that will mess up the rest of the animations, such as jumping, etc.

    Anyway, consider it a sidequest, perhaps. But once again, the main problem has been resolved, you have my thanks!

    The easiest way is to use a global variable to keep track of direction a player is facing.

    Global Variable Direction=0

    On player facing Left: Set Direction=1

    etc.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)