Creating platform ai?

This forum is currently in read-only mode.
From the Asset Store
Wanting to do a Shot n Run game easily? Here is your chance!
  • Hi, I'm wanting to make a enemy be able to walk and follow you and shoot when he see's you and he doesn't and be able to fall of ledges in side view.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Anyone.

  • You haven't posted what problem you're having, just that you want to do "stuff." You might as well post "I want to make a game."

    Be more specific. What about your AI isn't working? What methods have you tried to keep your enemies from walking off ledges?

    And if you're just asking "how do I make this" then I'm sorry, but that's up to you. If it's broke then someone might be able to help fix it, but you should at least try some things out first.

  • I just don't know where to start.

  • Think it out logically. Begin with small steps. When tackling a complex problem, always begin with the simplest thing first, then once that's done build on top of it with the next step. There are no quick answers to things like this.

    1. First, create a sprite.

    2. Now you want to make it move. There are several ways you could do this. You could give it Bullet movement, or you could manually update it's x, y coordinates. Have it move in a straight line, and then when it hits a wall, make it turn around and go the other way.

    3. Now that it moves back and forth, you want to have it stop at the edge of a ledge. The best way to do this is to make an invisible barrier that it can bounce off of. When it overlaps the barrier, it turns around.

    4. Maybe you want to have gravity so it falls off a ledge. Make your sprite move down 1 or 2 pixels every cycle.

    This can cause your sprite to get stuck in the ground. Make a loop that moves your sprite 1px up when it's overlapping the ground to push it out.

    5. Now you want it to follow the player when it "sees" it. You could do this by making the sprite detect when the player is within a certain distance.

    6. Now that it is aware that the player is within a certain distance, shoot an invisible object toward the player. If it hits the player, then the sprite "sees" the player. If it hits the background, the sprite does not see the player.

    7. Now if the sprite sees the player, make the sprite turn and face towards the player (similar to making the sprite turn around when it hits a wall).

    8. Making the sprite shoot the player is up to how you want the sprite to shoot. Do you want it to shoot at regular intervals? Do you want it to shoot a constant stream of bullets? Maybe you only want to shoot when the player is on the same vertical level as the sprite. Who knows? It's up to you.

    There... those are the basics. This doesn't cover things like acceleration and such. Your gravity will be linear instead of "y pixels per second squared," but you can ask for help with more natural gravity once you have basic gravity done.


    If you ask for help with one of the steps, I want to see a .cap showing that you have completed all the steps leading up to it or you'll get no response from me.

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