help : Consecutive attacks and animation

0 favourites
  • 3 posts
From the Asset Store
Game with complete Source-Code (Construct 3 / .c3p) + HTML5 Exported.
  • Hi to all!

    I just got stuck in landing some attacks for game character. i read some threads and tuts but i cant get it properly done.

    Here is a sprite of Zero that im using as a sample for my prototype in experimenting about attacks and changing weapons.

    1. What i want to do is land an attack if i press the button once and "attack 1" will play.

    but for the next, I cant make the second and third attacks when I press the button twice or trice.

    2. How do i make the end of the slash or attack will only the one who can trigger to hit the enemy. my problem here is that when im standing above on a hitable object or enemy and pressed the attack, it still get hit.

    3. when i press the attack and the attack 1 plays, the animation is a little messy and not centered. how can i make it centered then?

    hope you guys can help me, thanks :D

  • anyone?

    cant still do it right > <

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You'll want to use a few variables for this. One that shows what your last attack was, and a couple to act as timers. When you press the button to attack, check the state of the attack variables and do the logic accordingly.

    So if you press the button with all the variables at 0, it will do the first attack and increment the variable that tracks what your last attack was, then start running down a short timer variable. If they attack while the last attack variable is 1 and before the timer is up, play the second attack and reset the timer. Then do the same for the third. This will let you combo attacks together, while reverting you back to the first attack if you don't attack for too long.

    It can be a bit complicated, so if you aren't used to using variables you may want to read up on them a bit, and try to keep it simple at first. Maybe start by just implementing a single variable that increases by one with each attack, and plays a different attack animation based on its state.

    For making only a certain part of the attack hit the enemy, you'll want to spawn a separate "hitbox" object, an invisible rectangle that overlaps with the sword but not with the rest of the enemy. Give the hitbox a lifespan variable so it doesn't stay around after the animation, or just remove it when the animation ends. You can even change the size and positioning of the hitbox to match the sword in different animation frames, though that gets more complicated.

    If your animations aren't centered well, you want to change the hotspot, which is in the animation editor. It decides what point the animation is "centered" around, so you'll generally want it to be in a consistent place on the character.

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