How do I make enemies get pushed back when hit?

Get help using Construct 2

Post » Sun Dec 14, 2014 4:28 pm

My enemies have the Platform behavior on them (this is a side platform game). When the Player hits them with his weapon, I want the enemies to get pushed back, pause a little, and then pursue walking towards Player again.

Right now, when they get hit, I use the move forward -50 event, but the issue is that this forces them into walls. What's the correct way to push them back?
Check out my games on Google Play:
BEAST ATTACK (1,000,000+ downloads!)
ZOMBIE BASH (Android) (Launched Feb 17)
ZOMBIE BASH (iOS) (Launched March 17)
B
54
S
18
G
2
Posts: 436
Reputation: 5,582

Post » Sun Dec 14, 2014 4:43 pm

I don't know exactly how to do it right now but using timer might help to split this action on parts (push them back -> start timer "stun" for 0.5 sec -> on timer "stun" -> start moving them forward). ;)
B
13
S
4
G
2
Posts: 14
Reputation: 2,324

Post » Sun Dec 14, 2014 4:48 pm

@Bezza Thanks, this is helpful! I also fiddled around a little bit and decided to use angle of gravity as well, wait 0.2 seconds, and make the angle of gravity default again.
Check out my games on Google Play:
BEAST ATTACK (1,000,000+ downloads!)
ZOMBIE BASH (Android) (Launched Feb 17)
ZOMBIE BASH (iOS) (Launched March 17)
B
54
S
18
G
2
Posts: 436
Reputation: 5,582

Post » Wed Dec 17, 2014 10:39 pm

Gravity doesn't seem like the best way anymore. The movement is very artificial. Does anyone have other ideas on how to push enemies back? Perhaps 'move to location with a parabola'?
Check out my games on Google Play:
BEAST ATTACK (1,000,000+ downloads!)
ZOMBIE BASH (Android) (Launched Feb 17)
ZOMBIE BASH (iOS) (Launched March 17)
B
54
S
18
G
2
Posts: 436
Reputation: 5,582

Post » Wed Dec 17, 2014 10:51 pm

you need to check the space you are sending them too for a collision before you do the move forward. If that spot is empty then proceed with the move otherwise do something else....or nothing but not the jump back move.
B
28
S
5
G
2
Posts: 76
Reputation: 3,085

Post » Thu Dec 18, 2014 10:43 pm

Pennington Games wrote:you need to check the space you are sending them too for a collision before you do the move forward. If that spot is empty then proceed with the move otherwise do something else....or nothing but not the jump back move.


What event would you use for the move forward? Path finding and follow path?
Check out my games on Google Play:
BEAST ATTACK (1,000,000+ downloads!)
ZOMBIE BASH (Android) (Launched Feb 17)
ZOMBIE BASH (iOS) (Launched March 17)
B
54
S
18
G
2
Posts: 436
Reputation: 5,582

Post » Fri Dec 19, 2014 2:30 am

I did this a while back with bullet physics, setting the acceleration and deceleration based on a timer and the angle of motion based on where the player hit them from, it worked pretty well for a top down game
B
5
S
1
Posts: 59
Reputation: 497

Post » Fri Dec 19, 2014 2:57 am

@ChefSeth Thanks!
Check out my games on Google Play:
BEAST ATTACK (1,000,000+ downloads!)
ZOMBIE BASH (Android) (Launched Feb 17)
ZOMBIE BASH (iOS) (Launched March 17)
B
54
S
18
G
2
Posts: 436
Reputation: 5,582

Post » Fri Dec 19, 2014 4:06 am

You could also use the Vector X when using the Platform behaviour. So for instance when an enemy gets hit you could set the Vector X to an amount, say 200, for this example (try out a higher or lower amount to see the impact),
200 is a positive number so the enemy would "dash" off to the right - meaning you should check before the enemy takes the hit if the player/weapon, is left or right from the enemy that gets hit.
If the player is on the other side of the enemy, on the right (I'm guessing it's a sidescrolling platform game), and the player hits the enemy to the left side - use -200.
Hope that helped a bit :)
B
84
S
20
G
6
Posts: 175
Reputation: 8,156


Return to How do I....?

Who is online

Users browsing this forum: David181, evillair, Fenix18, Yahoo [Bot] and 45 guests