How do I make a no-hit death?

0 favourites
  • 4 posts
From the Asset Store
12 unique hits, slashes and spells in transparent PNG sequences
  • So I want to add a mechanic that kills the player if they use a certain attack (say the Space button) and they don't hit anything, then , they should die.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Event:

    On Space Bar Pressed

    &&

    [INVERT] Attack is colliding with [FAMILY OR ENEMIES] Action: Set [Life Local Variable] to 0.

    You can also set global variables such as:

    "Special_Attack_Used = 0"

    Event: 1. On Space Bar Pressed ; Action: Set Special_Attack_Used = 1

    2. Event: Set Special_Attack_Used = 1

    Sub-Event: 3. Attack is colliding with [FAMILY_OF_ENEMIES] Action: Destroy [FAMILY_OF_ENEMIES] ; Set Special_Attack_Used = 1

    Sub-Event: 3. [INVERT] Attack is colliding with [FAMILY_OF_ENEMIES] Action: Set [Life] to 0.

  • this won't work.

    since you set sub events - they will fire the same tick / next, and attacks animation won't end for let's say - 2.3 sec, and you don't know if it will hit, how long it flies and stuff. depends what kind of attack it is - melee or range?

    the solution is next:

    add local variable to attack named "didHit" with value 0.

    when you activate the hit with some key (for example space) - set the animation on and wait till it ends. if it collided somewhere set didHit = 1.

    once the animation ends - check if didHit is = 1, if it's 0 - kill player, otherwise don't do anything.

    now this applies good for melee attacks, but what if you want a range projectile to check if it collided? add the same variable to the fired projectile.

    on destroyed check if didHit is 0, if it is kill player, if not then nothing. ofcourse you will have to check if projectile collided and have a way to "terminate" projectile on miss... for example - starts with speed 400 and deceleration 100, after ~6seconds it will stop - therefore you destroy it when it reaches speed 0, which will trigger checking didHit. and ofcourse if collision happend you destroy it in that moment it hits (and set didHit to 1ofc)

  • You can also set the variable to that it's

    EVENT: After [Special_Attack_Animation] has finished; ACTION: Set Special_Attack_Used = 1

    Oh yeah you should consider what type of attack too. Thanks for that.

    If it's melee then it should be safe to do that ^. I'm assuming sprite is destroyed immediately and no Impulse physics is applies to the Opponent after the attack.

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