Simple beat 'em up enemy movement towards player?

Get help using Construct 2

Post » Wed Dec 11, 2013 2:46 pm

I am designing a cyberpunk game called "Psi" about a woman with psionic (mental) powers against a horde of nanobot created zombies and murderous machines. I am trying to make the enemies move towards the player's position without changing the angle of the sprites. In this picture, I'm simply trying to get the zombies to chase the mutant.



The closest behavior to what I want that I've found is "Accelerate CustomMovement 100 towards (Player.X, Player.Y)" but this makes the zombies accelerate and shoot past and then eventually reorient and come back, each time, overshooting it further. What I am wondering is, is there a simple move towards position command somewhere that I'm missing? If not, it seems like it would be a very simple thing to implement and would save people working on games similar to mine a lot of time. Thank you for any help.
Image
B
20
S
4
Posts: 382
Reputation: 2,964

Post » Wed Dec 11, 2013 2:51 pm

Did you look at the moveto example in the new project dialog?

Using bullet without setting angle is a possibility.
You could also use the moveto 3rd party plugin, you can find it in the plugin section.
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 » Wed Dec 11, 2013 3:02 pm

No. Thank you, I will look. I tried bullet behavior but it kept changing the angle of the sprites which made for a comical look and behavior.
Image
B
20
S
4
Posts: 382
Reputation: 2,964

Post » Wed Dec 11, 2013 3:05 pm

In the bullet behaviour properties you can set the set angle to no.
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 » Wed Dec 11, 2013 3:16 pm

OK, I did that. I set angle to no and added event, System every tick set angle towards Player.X, Player.Y, set bullet speed to 100. The zombies flip upside down and fly off the right side of the screen. I wonder what I'm doing wrong.
Image
B
20
S
4
Posts: 382
Reputation: 2,964

Post » Wed Dec 11, 2013 3:20 pm

I think you are setting the sprite angle instead of the bullet angle..

And probably you'll want to set the bullet speed back to 0 when the distance to the player is close enough.
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 » Wed Dec 11, 2013 3:22 pm

for each zombie
system compare two values : distance(zombie.x,zombie.y,player.x,player.y) < 50
zombie set bullet speed to 0
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 » Wed Dec 11, 2013 3:29 pm

When I try to set the angle of motion on the bullet, it only has one value. If I put in Player X or Y, in both cases, the angle of the zombie stays right but they move off of the screen. Sorry if I'm being obtuse and thanks for your help! How will I make the movement stop at a certain distance from the player?
Image
B
20
S
4
Posts: 382
Reputation: 2,964

Post » Wed Dec 11, 2013 3:29 pm

Sorry, I posted that last question before I saw your reply. Thanks!
Image
B
20
S
4
Posts: 382
Reputation: 2,964

Post » Wed Dec 11, 2013 3:31 pm

bullet set angle : angle(zombie.x,zombie.y,player.x,player.y)
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

Next

Return to How do I....?

Who is online

Users browsing this forum: Apollo14, MaujDeveloper and 3 guests