How do I make a movement system for my enemies?

0 favourites
  • 4 posts
From the Asset Store
Run and Jump in 3 Dimensions! Take your platformer to the next level!
  • 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!

  • 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

  • You could slow the enemies down and/or stop them from moving, depending on their distance from the ship..

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)