Creating platform ai?

For questions about using Classic.

Post » Fri Feb 22, 2008 7:14 pm

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.
B
4
S
2
G
4
Posts: 164
Reputation: 2,178

Post » Mon Feb 25, 2008 10:43 pm

Anyone.
B
4
S
2
G
4
Posts: 164
Reputation: 2,178

Post » Tue Feb 26, 2008 1:01 am

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.
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Sat Mar 01, 2008 12:07 am

I just don't know where to start.
B
4
S
2
G
4
Posts: 164
Reputation: 2,178

Post » Sat Mar 01, 2008 1:08 am

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.

Edit:
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.
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 3 guests