How do I make a movement system for my enemies?

Get help using Construct 2

Post » Sat May 16, 2015 12:07 am

Message: WatchCats is not yet permitted to post plain text URLS (300 rep required). 1 URLS removed. Why?
Hi!

I'm working on a top down shooter for my final college project, and my enemies movement is causing me lots of trouble. Its a space-ship shooter, where you're in control of a big capital ship. Now, I would like the enemies to follow the ship smoothly, and also not group up into one giant bundle of mess at the same time. I have tried using path-finding, however this results in the enemies going to the point of the Ships X and Y co-ordinates at the time it finds a path to them. Instead of constantly following the ship, they are instead going to places where the ship was.

By the time the enemy finishes its path, your ship has moved onwards, leaving the enemy ship trailing behind. However, by simply telling the ship to rotate towards the players X and Y co-ordinates, the enemy follows the ship fine. However, once the enemy reaches your ships X and Y, it starts freaking out and pinning around on the spot. Is there anyway to create AI that follows the ship smoothly from a top down perspective? I can't figure out how for the life of me.

Here are the screenshots of the ship before it hits the ships X+150, Y Co-ordinates and after. The blue ship flips between facing up and down very quickly, but you cannot see it in that picture. I included a shot of the event sheet for the enemy in there too. I am not sure how to make it so that people can download a copy of the game to have a look at, so I am really sorry about that.

Thanks for reading! This is my first post here and its rather late here (1 am) so I'm sorry if I've got anything wrong. Any advice would be appreciated, as I feel so stupid trying to make simple enemies move around. Thanks again!
B
3
Posts: 2
Reputation: 179

Post » Sat May 16, 2015 12:17 am

Hey WatchCats,

If your happy with the way it rotates to the X, Y position you could add another condition to compare the distance between the two objects, which could then tell the ship to stop (or fire if it was an enemy).

It's in the system conditions (compare two values). Then in the top section you type:

Distance(Object1.X,Object1.Y,Object2.X,Object2.Y)
is less than
Desired amount
ImageImage
B
119
S
23
G
7
Posts: 1,070
Reputation: 12,989

Post » Sat May 16, 2015 12:22 am

You could slow the enemies down and/or stop them from moving, depending on their distance from the ship..
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 » Sat May 16, 2015 10:23 am

GenkiGenga wrote:Hey WatchCats,

If your happy with the way it rotates to the X, Y position you could add another condition to compare the distance between the two objects, which could then tell the ship to stop (or fire if it was an enemy).

It's in the system conditions (compare two values). Then in the top section you type:

Distance(Object1.X,Object1.Y,Object2.X,Object2.Y)
is less than
Desired amount


Thanks! Saw your reply when I got up and put in it, and its working great now. Thank you!
B
3
Posts: 2
Reputation: 179


Return to How do I....?

Who is online

Users browsing this forum: evillair, LuciousBest, lukewasthefish, rbailey83, Solomon and 6 guests

cron