How do I slow down enemies from my weapon?

0 favourites
  • 5 posts
From the Asset Store
Futuristics Weapons Vol 1 includes 8 different weapons, in a total of 216 sounds
  • Not kill - but slow down the movement of an enemy. Basically, when the player shoots the weapon at an enemy, it slows down his movement, but then let's say after 20 seconds, the enemy moves at its normal speed. How would I go about doing that?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Do you have enough memory and speed?

  • give the enemy timer behaviour

    on enemy hit

    • enemy set speed
    • enemy start timer "slow"

    enemy on timer "slow"

    • enemy set speed to original speed
  • create family genEnemy -- Families let you make make stuff affect multiple objects - enemy a the flier - enemy b the slug w/e

    instance variables

    -maxSpeed

    -slowTimer

    genEnemy on created

    - set max speed to genEnemy.maxSpeed

    - set genEnemy.slowTimer to 0

    on genEnemy hit

    - genEnemy set max speed to ((genEnemy.maxSpeed*(8/10)) - for 20% decrease

    - set genEnemy.slowTimer to 20

    if genEnemy.slowTimer = 0----invert --- i.e. if slow timer does not = 0

    -set genEnemy.slowTimer to (genEnemy.slowTimer - dt) -- might need to be a sub event ---- system - every tic - set genEnemy.slowTimer to (genEnemy.slowTimer - dt) --- not positive though =p

    else

    -set genEnemy max speed to 400

  • The easiest way to handle this type behavior is with either instanced variables inside the affected object or with global variables with settings the objects scan for.

    The examples above cover this pretty well.

    I would add that I have had no problems using a wait action when the delay is small. In my current project turrets and other enemies are "turned off" for 5 seconds when hit by a certain type of player weapon. I use instance variable in each called CoolDown (also used in my weapons to stop spam firing) and turn it to 1 when they are hit with the turn-off weapon and then do a wait-5s, CoolDown = 0 actions.

    I just add If CooDown = 0 in all the important turret stuff and it works fine.

    In your example I would do something like:

    Enemy on created bullet speed 300

    Enemy on collision with SlowDownThingy set enemy bullet speed 150

    wait (however long)

    Enemy set bullet speed 300

    if you want something to determine when it can go back to normal speed then use an instance variable inside the enemy object.

    Enemy on created bullet speed 300, set SlowDown 0

    Enemy compare instance variable if SlowDown = 1 then set bullet speed 150

    Enemy on collision with SlowDownThingy set Enemy/SlowDown to 1

    on Later event set Enemy/SlowDown 0

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