How do I make attacks kill enemies?

0 favourites
  • 3 posts
From the Asset Store
Pixel Enemies for SHMUP consists of 38 enemy ship sprites to be used in your game.
  • I have this sprite with an attack animation set to the 'spacebar' key. Whenever it's pressed and collides with an enemy, I want the enemy to die. But instead every time I press spacebar on collision with the enemy nothing seems to happen.

    I am using a boolean variable that sets to true when the player collides with the enemy. I feel like I am doing something very wrong here?

    Also, if say the attack animation just constantly plays after pressing spacebar once and keeps hitting things non- stop, would I need to put a 'is animation attacking playing' then set attack variable to false?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • "On Collision" is a triggered event, which means it lasts only one tick. "Keyboard On key pressed" is also a triggered event, also lasts one tick. (all events in Construct that start with the word "On" are triggered)

    So you need to be very-very lucky to press the spacebar exactly at the moment of collision.

    The solution is to use "Is" conditions instead - "Is overlapping" and "Key is down". Something like this:

    Player is overlapping enemy
    Space key is down
    Enemy health >0 
    ......... Enemy set health to 0
    ......... Enemy start animation "Death"
  • Oh,thank you! :)

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