How do I Make An Enemy Sprite Inactive Upon Defeat?

0 favourites
  • 5 posts
From the Asset Store
Be discreet and rescue your friends from behind enemy lines.
  • Hello Wonderful People!

    I am new to Construct 2. I am making an 8-bit Platform game.

    When I defeat an enemy sprite, I don't want it destroyed-- I want it to run off screen in a fit of tears. I figured out the running off screen part, but unfortunately if it collides with my player on the way out my player still takes damage. Is there a way to make the enemy sprite inactive, or un-collidible, upon defeat? As in, my player sprite can no longer interact with it?

  • Well, you just have to disable the part which makes the ennemy affect the player's health. I presume it's like "on collision with player" => player health = player.health - 1 or something. You can make a boolean variable "alive" initialised on true, and when this variable is false (after the ennemy's deafeat), then the ennemy doesn't affect the health anymore. For example :

    [event]

    Ennemy : On collision with Player

    variable alive = true

    [action]

    playerHealth = playerHealth - 1

    [event]

    Ennemy : On collision with Player

    variable alive = false

    [action]

    playerHealth = playerHealth

    It's an idea, I didn't tested it, but that's how I'll try it.

  • Well, you just have to disable the part which makes the ennemy affect the player's health. I presume it's like "on collision with player" => player health = player.health - 1 or something. You can make a boolean variable "alive" initialised on true, and when this variable is false (after the ennemy's deafeat), then the ennemy doesn't affect the health anymore. For example :

    [event]

    Ennemy : On collision with Player

    variable alive = true

    [action]

    playerHealth = playerHealth - 1

    [event]

    Ennemy : On collision with Player

    variable alive = false

    [action]

    playerHealth = playerHealth

    It's an idea, I didn't tested it, but that's how I'll try it.

    2nd Event and Action would be pointless here. You are already testing against 'alive' variable in the first Event and the Playerhealth is only decreased if 'alive' is true - no need to test for false.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Indeed, the first event should do the job. Thanks for this correction

  • Got it! Thanks!

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