How do I make a damage taken from a single enemy?

0 favourites
  • 5 posts
From the Asset Store
Give Sound to the enemies that are part of your game! :)
  • Guys another problem. When my enemy take damage the cannon on it flash but not the single cannon, all the cannon in the game. How can I put that when the single enemy that take damage flash the single cannon of the enemy and not the all cannon?

  • You need some way to pick the specific cannon instance that you want to flash.

    Without seeing your game it's difficult to know what to do based on your setup. A bit more info will help.

  • I made an enemyship with a separate sprite on it called "cannon" and they spawn random on the map. When my ship shoot to one of this enemyShip it flashes and then die but if there are more than 1 ship on the map when I hit an enemyShip flashes only the base of enemyShip but all the cannon on the other enemyShip.

    Now i send the screen of the code

    I explain better:

    When I hit an enemyShip, only the enemyShip hitten flashes but also the cannons on the others enemyShip

  • That's because the "on collision with" condition picks the ship that has been attacked but no cannon is selected, so when you ask the cannon to flash, the code is asking all of the cannons in the game to flash.

    An easy way to solve this would be to add the cannon to a container with the ship. That way when the ship is picked, the cannon on that ship is also picked.

    You may need to modify the way you spawn the ships if you add the cannon to a container as any object in a container is also created when the initial object is created.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • if you don't want to go the container route for any reason, you could also do it by adding these events.

    EnemyShip is Flashing

    Cannon overlapping enemy ship

    trigger once

    --- Cannon Start flash

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