How do I slow down enemies from my weapon?

Get help using Construct 2

Post » Sat Sep 27, 2014 4:49 pm

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?
B
10
S
3
Posts: 20
Reputation: 690

Post » Sat Sep 27, 2014 4:53 pm

Do you have enough memory and speed?
B
6
S
1
Posts: 34
Reputation: 474

Post » Sat Sep 27, 2014 4:57 pm

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
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Sat Sep 27, 2014 9:38 pm

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
B
9
S
2
G
1
Posts: 36
Reputation: 1,381

Post » Sat Sep 27, 2014 9:44 pm

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
Check out my completed games on the Arcade! Capt. Doe Save the Universe! & Clicker Wizard!
B
66
S
17
G
8
Posts: 637
Reputation: 9,370


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 17 guests