Animation priority CLASHES with other animations ??

0 favourites
  • 6 posts
From the Asset Store
3 pixel charaters with over 8 animations each + animations with a gun
  • Hey All!

    Continue to my latest thread where I Re-Program the ALL base engine of my game:

    I'm working on the Player's basic mechanics now and how he will react as a platformer while interact with other objects such as enemies.

    Since I can't share the capx, I'll do my best to describe and SHOW the issue and maybe you can help me out here:

    The short version:

    The Problem: Player's Animation Priority is acting weird with a delay.

    When the player collide by enemy: "HIT" Animation stuck on first frame for a bit then playing. My guess is because of the Platform animations priority: IDLE / WALK on floor / not on floor etc..

    The long version where I try to describe best:

    (Sorry about my bad English.)

    I have: INPUT and ANIMATION GROUPS so I can handle the Knock-Back (ignore INPUT on enemy collision).

    So far so good, everything works!

    Originally, the player also Flashing when collide with enemy, but for better visual example on the specific animated GIF I disabled it so you can see the issue.

    THE ISSUE:

    As you can see the on collision the player is "trying" to run the "HIT" animation from beginning but it stops for a few ms and then begins.

    I tried MANY ways to solve this:

    • I made the animation to start when the variable IGNORE is "on" and back to idle when it's "off".
    • I tried when Flashing is on run the "HIT" animation, and back to idle when it's finished.
    • I tried to make a dedicated Boolean variable for the "HIT" animation condition.
    • I tried to cancel other animations while HIT is on, got messed up results.
    • I tried to "force" the HIT animation using every tick.

    All these and other attempts failed... (probably because I don't understand Construct yet, still a newbie)

    In my simple brain it should be easy:

    as long as IGNORE variable is "on" the "HIT" animation is playing. when it's "off" change to IDLE animation.

    Right now on my current code, the IGNORE works on collision for 1 second (with or without Flashing) so it's not depending on the flashing time. there is a "wait 1 second" on the collision event which ignore my INPUT group and it works fine.

    Player "HIT" Animation is 2 frames (loop forever just like idle so I can use stop it when I want)

    My Conclusion:

    After some tests, when I disable these 2 events:

    • Platform is moving + Platform on the floor = Set animation to "WALK" (play from beginning)
    • Platform on stopped + Platform is on floor = Set animation to "IDLE" (play from beginning)

    ONLY THEN the "HIT" animation works correct as it should once the collision happen for 1 second (that's what I want) then back to IDLE.

    BUT... now there are no WALK and IDLE animations because these are the BASICS of my player animation movements.

    I do have other animation conditions such as JUMP, FALL, Landed.

    I disabled every single one to make sure that the problem is related to what I've mentioned above and it make sense that it can't play the "HIT" animation because it must play the other animations first, only THEN it will play the "HIT" that is why there is that DELAY that looks like it freezes the first frame of the "HIT" animation and then when the Player stops it will continue playing it.

    So what is the solution?

    How can I set the priority of the "HIT" animation to take-over all the others while IGNORE variable is "on" ?

    The only way I can think of right now is a bit more advanced for my level but my stuuupid brain tells me to try and build some kind of ANIMATION PRIORITY SYSTEM using a variable to control each animation on specific events to overwrite each other when needed.

    it's nice in theory and all, but please consider I'm still new to Construct and it's I'm learning as I build this game, I still have much more to learn but I hope you can guide me to a simple-as-possible solution.

    Maybe there is a plugin, or built-in feature to solve this?

    maybe my conclusion is wrong and it's not even the issue and the solution is totally different?

    Yes... I'm very confused.

    Thanks ahead for any help!

  • Your issue: As you can see the on collision the player is "trying" to run the "HIT" animation from beginning but it stops for a few ms and then begins.

    i experienced something similar the past few years the solution was because of the way i was arranging the condition for example:

    when hit happens > animation 1 
    if landed behavior etc .... < this takes about 0.1 0.2 seconds to calculate and trigger the actions.
    if got hit with count objects ... < same here, depends on how many objects the plugin has to count and verify collisions with.
    if animation 1 finished play animation 2
    
    ////////////// this is usually how people code things in C2/C3 and that is a bad adoption, cause is against how Construct Works /////// this is the nr 1 cause in slow performance and "broken" code in Construct, in my experience.[/code:1wd4pmc3]
    
    the fix is simple  by moving the last condition after 1st animation or put 1st even should fix your delay
    
    [code:1wd4pmc3]when hit happens > animation 1 
    if animation 1 finished play animation 2
    if landed behavior etc ....
    if got hit with count objects ...
    [/code:1wd4pmc3]
    or in another case, you might want to check for collisions first then trigger animation in that case the following format should apply.
    [code:1wd4pmc3]
    if landed behavior etc ....
    if got hit with count objects ...
    when hit happens > animation 1 
    if animation 1 finished play animation 2
    [/code:1wd4pmc3]
    
    also make sure your animation frame speeds are default or to 0.1 or what the default speed is, do not confuse frame speed with animation speed they are different things.
    
    another thing to check, any "wait" or "every 1 second" conditions, between the conditions you have, needs to be removed from there and place at bottom of the event sheet, that way all code runs normal and wait happens after all animations and visuals are fast played, the "wait" & "every 1 second" conditions dont only apply to the condition are on, but to every condition in your event sheet that is under them, same thing applies to conditions that take a long time to calculate things as explained above they will delay the entire game system if placed 1st, C2/C3 as any website html5 code (css style, js etc), will read the code from top to bottom, therefore you need to prioritize the order of the conditions(this is a pretty well known issue, that is to be taken in consideration when you optimize your game/app for speed... but im guessing not many people do optimizations on their game).
    
    if any of the above are not fixing your issue, one simple trick is to increase the speed of the animation that gets lagged, and to last less then it does now, as i see your animation is pretty fast, and natural, there is only a slight delay, if you decrease the time should last, that will "fake" the fast movement, (if ur lagged animation has the same frame duplicated just remove some of the frames, since they are the same frame duplicated and there will be no changes in visual experience outside how fast it plays).
  • Thank you so much for the detailed reply.

    First I would like to try fix it with your suggestion of the conditions the problem is I'm not sure how to do the:

    when hit happens > animation 1 [/code:1lz2jbwn]  for example. I could found compare animation frame I guess it's not the same.
    
    The other thing is:
    My event sheets are separated, one dedicated to the enemies (all enemies, each one in group with anything related to itself and the player) so I will be able to use Enemies family if needed. for now I have only 1 enemy to work with anyway.
    
    So, the collision between the Player and the Enemy is split to 2 events, that's where I scratch my head while my event sheet is very organized.
    
    As you can see on the images attached, the collision is based on the Enemies Event-Sheet.
    While the "IGNORE" works on the Player_1's Event-Sheet. 
    [h2]I disabled "flashing" for this test, it is related to the invincible time which works perfectly fine.
    Line 22 and above is the SAME for the other side of the knock-back no need to show it again.[/h2]
    
    On Player event I selected to show which are the 2 events that if I disable, EVERYTHING WORKS consider walk and idle won't act correct as explained on my original post.
    
    ENEMY EVENT SHEET specific part of the knock-back + ignore for 1 second:
    [img="https://i.imgur.com/TPwsNGe.jpg"]
    
    PLAYER EVENT SHEET - Animation priority issues to fix:
    [img="https://i.imgur.com/YBCOwq6.jpg"]
    
    I'm guessing that I need to mess with the code on the  "Ground animations"  part to solve the issue, 
    But I'm not sure how exactly... noob mode + confusion level = HIGH   
    
       Can you please help me out guide me how to do it or show screenshot? mini-capx?
    Any visual way will probably help me try your solution it make lots of sense to me and I rather try it before the "fake animation" playing with speed and what not.
    
    Thanks ahead!
  • I CAN'T BELIEVE MY SYSTEM ACTUALLY WORKED!

    update:

    Remember how I was thinking about a crazy "idea" of making an Animation Priority-System on my first post?

    So... I decided to give it a try, basically because I didn't know how to accomplish the other solution which probably would be easier but as a newbie this is what I could think of.

    I wanted to share the Event-Sheet so more people will be able to see the solution and it may help others in the future BUT! I can't fit the all thing in one image when capturing...

    I wish we had a BUILT-IN FEATURE for capturing full event sheets within Construct 3!

    is this feature already there and I'm not aware off? if YES please let me know.

    So far it works like charm!

    I'm glad I didn't have to use fake animations, speed changes and such.

    I got much more control on ANY animation WHENEVER I need, I'm impressed by this tiny system and I hope it won't disappoint me on more complex parts of the game development.

    Here is a visual example:

    I use some slow-motion for my tests, that's why it's slow in some parts.

    And now, for the more complex part:

    "STOP PLAYER when attack on any condition" such as: Attack while Jump, Attack while walk, while fall, etc..

    It's not like the IGNORE, but it should stop the player, I may try SPEED = 0 or something first.

    That's why you see the "Movement" variable / text on my GIF...

    OH MY! I had so many issues with it on my last attempt... now that I Re-Code everything from scratch it may be working, I'll give it a try.

    Any suggestions on this will be great!

    Thanks ahead.

  • Thank you so much for the detailed reply.

    I could found compare animation frame I guess it's not the same.

    ENEMY EVENT SHEET specific part of the knock-back + ignore for 1 second:

    No problem, was my pleasure.

    Animation frame count works, faster then wait condition between, as long as the play animation is not interrupted by what ii said bellow.

    You could set the ignore off after the animation hit has finished playing that way you eliminate the wait 1 or 2 seconds condition which is causing your delayed animation. see capx bellow as how to convert it with simple default C3 conditions and no wait actions or every 2 conditions, i also left a conclusion there, in case things are confusing, however i might of made the conclusion a bit confusing by itself. the idea in the end is try code your game animations without any wait actions in the animation code. just trigger the animation when is needed and not mix it with the delay of other conditions mid animation playing, hope it makes sense, and helps you in your development, and sorry for the late response.

    Download: animation example.c3p

    However your animation control system is probably better. But i bet you included the event system above and eliminated all the wait conditions and expressions from it. Which kinda reaches what i was saying.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thanks again ! I will have a look on your example as soon as I get a chance!

    It sounds interesting, I will have to see maybe I should or shouldn't change my animation priority system.

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