Zombie follow the Player

Get help using Construct 2

Post » Wed Sep 05, 2012 10:20 am

Hey all.

I'm making a 2d sidescroller with construct2 and I found that there's not a simply method to make a sprite follow another sprite horizontally.

I need this because I'm making a zombie game but ofcourse I NEED a zombie that only can move horizontally (if he need to jump I know how to do that). A Pathfinding behavior/plugin doesn't worked and I've searched for another method to do that but found nothing.

Can you help me? PLEASE!
B
17
S
4
G
4
Posts: 104
Reputation: 3,950

Post » Wed Sep 05, 2012 12:28 pm

Hello,

Here is a possible way of doing what you want. Hope it helps.

http://sdrv.ms/Q0bVd7
B
19
S
8
G
4
Posts: 11
Reputation: 4,509

Post » Wed Sep 05, 2012 5:34 pm

Use distance() to check if the player is far from the zombie.
Compare player.x with zombie.x, if player.x > zombie.x, it means player is on the zombie's right.
Use custom movement or platform behavior to make the horizontal speed of the zombie go toward a the player.
Else check the opposite, how I usually do jumps is I place an invisible collision block called "jump" and if the zombie collides with it, it makes the zombie simulate jump or add velocity upwards.
B
36
S
10
G
6
Posts: 948
Reputation: 11,101

Post » Wed Sep 05, 2012 7:48 pm

@oravalag I didn't open it because the Rory answer worked :P
@Rory Thanks. I finally made it. For the jump if there is any obstacle I've made a "If velocity is equal to 0 -> Simulate Jump". But I don't know if this will cause any errors or what.
B
17
S
4
G
4
Posts: 104
Reputation: 3,950

Post » Wed Sep 05, 2012 7:56 pm

Glad to be of help!

I wouldn't want my NPCs to walk into walls before they jump.
In Game Maker I used to check if there was an object located at the position ahead of the NPC about 30px away.

So I would check the NPC velocity, if it was negative, I would check NPC.X - 30, if there was a object at the position.

I can't think of any solution for this in C2 at the moment, too tired. But my workaround for now has always been to use a specific action collision box, like a "NPC touch this - jump collision object"
B
36
S
10
G
6
Posts: 948
Reputation: 11,101


Return to How do I....?

Who is online

Users browsing this forum: 99Instances2Go, Colorfish and 19 guests