How do I let a enemy walk to the player

Get help using Construct 2

Post » Tue May 06, 2014 5:33 pm

Hi together,

I want to let my enemies move to the player after they have been created. It's a very simple game. I have a player who is able to move left and right and to jump. The game spawn several enemies on the screen. Now the should "attack" the player and move to his position (player.X, ground.Y). And if the in a specified range the should do a action (like shoot or something like that).

But i'm not quite sure how to set this up. Has anyone an idea?
Image Image iTunes: Match3 | Google Play: Match3
B
109
S
40
G
31
Posts: 1,177
Reputation: 29,418

Post » Tue May 06, 2014 5:42 pm

If enemies.x < player.x , enemies.x=enemies.x+1 else enemies.x=enemies.x-1
if distance(enemies.x,enemies.y,players.x,players,y) < whatever then action whatever .
What I know would fill a Book , what I don't know would fill a Library
B
37
S
12
G
29
Posts: 331
Reputation: 16,499

Post » Tue May 06, 2014 5:54 pm

Hi :)
Thanks a lot for your fast respone. I tried to set this up, but the enemie doesn't move.

Image

Is that right?

Edit: forget it, found my problem ;) Thanks a lot :)
Image Image iTunes: Match3 | Google Play: Match3
B
109
S
40
G
31
Posts: 1,177
Reputation: 29,418

Post » Wed May 07, 2014 9:17 am

Hi again,

I tried to set up this with the distance, but I'm not sure which event i should use. Can you set it up and send me a screenshot like i did above? Just the distance event ;)

Thanks a lot!
Image Image iTunes: Match3 | Google Play: Match3
B
109
S
40
G
31
Posts: 1,177
Reputation: 29,418

Post » Wed May 07, 2014 10:45 am

AndreasR or you could use Bullets behavior and set angle toward position and use player as your position
B
257
S
43
G
15
Posts: 1,992
Reputation: 41,535

Post » Wed May 07, 2014 10:58 am

Hi Lordshiva1948,
Thanks for your reply. I already have set it up like grandpa said :) But do you know how to let the enemy do an action if a certain distance between enemy and player has been reached?
Image Image iTunes: Match3 | Google Play: Match3
B
109
S
40
G
31
Posts: 1,177
Reputation: 29,418


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 22 guests