[SOLVED] Any ideas? Enemies go into proper State/Animation with one Attack, but not another

0 favourites
  • 12 posts
From the Asset Store
2D fighting template based in the game that defined the fighting games genre.
  • Hello everyone :)

    I'm having a spot of trouble pinpointing the issue with a bug in my main project right now. I've created an EnemyDamage Function. It should put each Enemy into a state/animation of being damaged if health is above 0, or a state/animation of death if health equal or below 0 and fade.

    It works fine with my Player's melee Attack. When the hitbox overlaps the enemy, they go into their proper animations, and flash, or fade depending on the level of health variable.

    But, if I do the Player's Slide attack into them pictures below, it does not put them into the proper animation for that state. I also have an invincibility pickup for the Player. When the Player runs into any of the PlatformEnemy objects it calls the same function, except takes off 2 health(which puts the enemies health to 0. That also does not work as intended. And again, it's a condition where the Player Box collides with the enemy, with a boolean for invincibility set to true.

    So it seems to be an issue with the Player Box(in particular states) colliding with enemies, where the animations do not change properly on the enemies.

    Screenshot of EnemyDamage Function: EDIT: Please Note: The Wait 0.1 Seconds, and Stop Animation, were put in to try and fix the issue, before taking screenshot below.

    Screenshot of a the Sliding & Melee Attack calling the Function above:

    As always. Any help is greatly appreciated! Thank You :)

  • There is probably a chance that enemy health exactly at 0 and subsequently won't trigger the condition. What if enemy flashing during damage so it won't execute subevent as intended.

  • That's for your input alextro

    What is strange is that it works just fine for the melee attack. And, not the sliding attack, or with invincibility. Both TakingDamage, and Death animations play fine on melee attack hitbox collision, and not the other forms of damage(where PlayerBox collides with the enemy(as in sliding or invincible).

    The sliding attack takes off the same amount off of Health variable as the melee attack. So it's not equaling 0, until the second hit of either melee or sliding attack.

    When it reaches 0 on the second hit of a melee attack it plays the Death animation, while fading as it should. I would think both collisions would work in the same way. As they are essentially doing the same exact thing. Running the function, and taking 1 off of the health variable.

  • You didn't tell us what the outcome is so it's more difficult to guess. I would debug the functions with some logging so you know what's being triggered. This could be a case where when you slide both of the boxes hit the enemy so it runs the function twice and conflicts. Or maybe the player states are wrong and it never triggers.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • While using the sliding attack(regular or with jetpack), as well as colliding with enemies with invincibility active. The outcome is: During the first hit, the enemy flashes but goes back into attacking/walking state & animation depending on the usual conditions for those states. During the second hit, the enemy fades while going back into attacking/walking state & animation.

    The function itself works flawlessly for melee & ranged attacks(melee using a spawned hitbox, the ranged being a bullet object), but not for the Sliding attack, or when enemy is taking damage while the player has the invincibility power-up active. To me it seems to be an issue with conditions where the PlayerBox is colliding with the enemies. Either while sliding/jetpacksliding, or while colliding with the invincibility mechanic active.

    The only hitboxes being used is one for the player attacks, then another for enemies' attacks. The ranged attack uses a bullet object for collision. For Sliding Attacks, and Invincibility it's using the PlayerBox. Which has the animated Player as a child laid overtop. The Player itself has collisions disabled, and all collisions are handled by the PlayerBox. the PlayerBox colliding with the enemy during one of two sliding attacks, or during the invincibility power-up is calling the EnemyDamage Function for those two(which are having the issue of not holding the enemies in the proper animations).

    As pictured. I used Trigger once in the Function, as well as a Collision check for the PlayerBox, rather than an Overlapping check. To not have the action performed twice right after each other. Even so, if that was an issue the Melee attack hitbox lingers for 0.2 of a second. Which would be about the time than it takes to slide past an enemy, or run right past them with invincibility activated.

    I've been picking away at this small bug, here and there for a while now. I can post images of entire event sheets if that is more helpful. I'm about to get on for an hour and a half live stream I host every night, in 15min. But, can check back here afterwards.

  • So it is working then unless you hit them a second time? There's no mention of the invincibility thing in the screenshots. That trigger once you can remove it is redundant here and doesn't do much. If the problem is it is dying when it is meant to be invincible then need to see those events. Also waits are generally bad in functions, not sure if it's the problem here though, but you should remove the wait 0.1 seconds and replace the 2 second wait with a timer on the enemies and use on timer ended which is better.

    "The outcome is: During the first hit, the enemy flashes but goes back into attacking/walking state & animation depending on the usual conditions for those states. During the second hit, the enemy fades while going back into attacking/walking state & animation."

    So what are you expecting to happen if an enemy is hit while 'waiting for 2 seconds' and dies? Are they meant to be invincible while waiting? Not really understanding the game or the logic behind the waits.

  • Basically. When the player attacks using melee or a bullet it works just as desired. I also added that wait 0.1 as a test, and removed it after uploading the screenshots.

    So, with a melee attack, the first attack makes the enemy flash, while playing the "TakingDamage" animation. Then moves back into "Walking" state, or the "Attack" state if the Player is within a set range. Then on the second attack, the enemy fades while playing the "Death" animation(as health reaches 0). Then gets destroyed at the end of the fade behavior(in the behavior preferences). Just like it shows in the EnemyDamage function in the screenshot.

    But.. When I perform the slide attack as in the second screenshot. Where it shows PlayerBox on collision with PlatformEnemy in either "JetpackSliding" or "Sliding" PlayerState. It does everything except play the proper animations. So the first hit with a slide attack. The enemy flashes, loses one health, while moving back into Walking or Attacking animation instantly. On the second hit, the enemy fades while moving back into the Walking state(which are the enemies default state). If player is within range they will go back into Attack state. The Walking, and Attack states are called depending on the distance to the player, and LoS.

    So everything is working as it should. Except the "TakingDamage" animation for that state on the first hit of a slide attack, and the "Death" animation for Death state on the second hit of a slide attack do not play their related animations. They flash, lose health, fade, and destroy at the end of the fade. But, do not play the animations that corelate to their HP values, and the state the function puts them into. But, they do play the animations perfectly fine if hit with the Melee Attack HitBox, or a Bullet object.

    It's really strange to me, because I am using the exact same function. And, as you can see in the second screenshot. I am calling the function the exact same way regardless if it is the Melee Attack, or the Sliding Attack. Animations work just fine for the Melee Attack(and a bullet as mentioned, but not in screenshots), but not for the Sliding Attack, or one other attack. And, I'm calling them in the exact same way. Works for one, but not the other.

    I'm not sure how else to explain it.

  • Hmm for the first hit you mentioned only animation (implying the animation is wrong but take damage state is still set) but the second hit you mentioned state, are you sure it's not that the state is wrong for both? That would make sense, it means the slide attack probably does something different to override the states but we can't see those events. Have a look at the slide attack and see if it would make the enemy change state to walking. Or if it's not that then it must be override from LOS, something that doesn't occur with melee attack for some reason but does with sliding attack.

  • I'm sorry for all the confusion. I'm always super helpful for you trying to help me out lionz. You have no idea haha. I often have trouble conveying concepts, and the way I sort things out in my head into words... Even in conversation.

    It's the state that is not changing, and that means, the animation for that state does not play when it should, during those types of attacks. I update the animation every tick to match what is currently held in the variable, "PlatformEnemyState".

    I think you are absolutely right. It may be LoS like you just said. Actually, now that I type that. I think I may know right where the bug lies. I'll be back later. Thanks so much for all of your time and help again lionz

    I'm the type, to almost never reach out for help, even in real life. But, when I do. You have no idea how much I appreciate it when someone does their best to do so.

  • I've got it mostly fixed at this point. I had to just delete a few event blocks. The only issue now is my ninja enemies are not moving back into Walking after they change their attack, or ranged attack state/animation.

    I'm happy with the progress with this bug. It's been irritating me for a while now. But, time for some rest and sleep. I'll tackle the rest tomorrow afternoon.

    Thanks again for all the help lionz. You pointed me in the right direction for sure. I was looking in the totally wrong areas of my Event Sheets.

  • Aight np good luck

  • Thanks again lionz! The bug that has plagued me off and on for a couple weeks, is finally sorted! 😃 What a great feeling it is, when you finally figure out what is going wrong, and mucking up a feature in a project.

    I'm learning more and more, how particular Construct 3 is, with the processing of conditions/events from top to bottom. All, I needed to do was delete one entire Event Block, which was unnecessary. Then add a couple more conditions to an OR Block, which checks the PlatformEnemy's state, then sets them each back to "Walking" through a Sub-Condition that checks to see that it is NOT in states "TakingDamage", "Death", and has lost the LoS to the PlayerBox.

    The real clinch, was making sure the check in the parent Block. The one checking to see if PlatformEnemy is in various Attack states was checking states in the proper order. I had all the state checks in there, and still wasn't working properly. Then I moved the check for the "Attack" state, above the "RangeAttack" state check, followed by a "SayNo" state check condition. That last one is used by the Sensei, who takes no damage, and simply wags his head no at the Player.

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