How do I make an enemy move away from an object upon contact

Just started using Construct 2? Post your questions here

Post » Thu Mar 19, 2015 2:48 pm

Hey, I've been making a zelda clone and this is what I've got so far: h t t p s ://vine.co/v/OV3adl6DOOK

I want to make it so that the enemy jumps in the opposite direction when it gets hit by the magic attack. I'm pretty sure this is where Custom Movements come in handy, but the manual isn't very helpful. Any clue?
Last edited by twoshoelaces on Fri Mar 20, 2015 3:48 am, edited 1 time in total.
B
7
S
1
Posts: 15
Reputation: 355

Post » Thu Mar 19, 2015 4:58 pm

use set vector X or Y action
Image
B
57
S
13
G
6
Posts: 271
Reputation: 12,103

Post » Thu Mar 19, 2015 5:13 pm

danuyos wrote:use set vector X or Y action

in 8 Direction? I can't, because I need the enemy to move in the opposite direction of the attack, and the attack could come in any direction. Unless I'm wrong, vector X or Y only lets you move in specific directions.
B
7
S
1
Posts: 15
Reputation: 355

Post » Thu Mar 19, 2015 10:44 pm

I'm going through the manual again. If anyone has an idea, please speak up!
B
7
S
1
Posts: 15
Reputation: 355

Post » Fri Mar 20, 2015 3:49 am

I can't find anything in the manual that applies here. Any help?
B
7
S
1
Posts: 15
Reputation: 355

Post » Tue Mar 24, 2015 5:36 pm

twoshoelaces wrote:in 8 Direction? I can't, because I need the enemy to move in the opposite direction of the attack, and the attack could come in any direction. Unless I'm wrong, vector X or Y only lets you move in specific directions.


When your character hits an enemy, you need to find the angle between the enemy and the character, then move the enemy 180 degrees from that angle.
I've never used the 8 direction behaviour, so the logic may need some tweaking based on it's properties. Sorry, I'm not at home so I can't work out a more elegant solution for you.
Be sure to check out my Metroidvania game, A Hole in the Earth
B
59
S
24
G
3
Posts: 359
Reputation: 5,683


Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 1 guest