How do I create an infection

0 favourites
  • 3 posts
From the Asset Store
Fully commented source code/event sheet & sprites to create a space shooter game
  • Hello fellas constructors,

    Luckily this is not a medicine question but code!

    I have been working lately on a super hero skill which infects enemies when the hero collides them, leaving a goo that if it's touched (overlapping) by the hero for a second time it will stick him to it till the infection disappears after x seconds.

    I have tried a few codes but always get problems specially when the hero is quite close to the enemy (I think it recognizes the overlapping as a collision) and the infection blinks on and off. Also, I'd like to know how do I achieve this having 12 enemies in the same level, which in most of the cases they won't be all infected at the same time.

    Thanks in advance for any help the community can provide!

  • I would give the enemy an instance variable boolean "infected" and a timer behaviour

    player on collision with enemy

    --enemy is not infected

    enemy set infected to true

    -- else player pin to enemy

    enemy infected is true

    system trigger once

    enemy start timer "infected" for 4 seconds

    enemy on timer "infected"

    enemy set infected to false

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Wonderful Stain, it worked like a charm! I also made some tweaks and added another timer for the goo, so the hero can be trapped if it touches it as well.

    I didn't know how powerful the timer behavior is. Thanks a lot, cheers!

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