AI Awareness

This forum is currently in read-only mode.
From the Asset Store
Units do not overlap each other and use different ways if there are several free ways.
  • So, I've been scanning the forum for answer (like a good little forum user) but I've come across a question that needs professional help. Lol.

    So, I'll just post the .cap and let you examine it as I'm asking these questions.

    http://dl.dropbox.com/u/33283294/zombie.cap

    Basically, what I'm attempting to do is program the AI for a zombie game. They way I started was just using the Line of Sight behavior. It was awesome and worked perfectly. Until I turned my sprites solid. Then, that ruined it because as I learned, the LOS runs off hotspots. So, back to the forum. I learned you can shoot an object at the player if is within the LOS of enemy and if it hits him, viola!

    However, this only works with one enemy onscreen. I want individual enemies to have to see the player before attacking. The way I have it (since I don't know what I'm doing) is every zombie will fire a detector at the player (which works) but as soon as one hits him, ALL the zombies go after him. I need a way to make the zombies INDIVIDUALLY aware of the player. (by means of a private variable)

  • I have had the same problem in my game, I haven't come up with the solution I'm going to try for real yet, but here is how I think I'll do it.

    Create an object called "detector" and put it in the container of your zombie. This creates one for each zombie, and when you perform a "for each object" on the zombies, it will select the right contained detector.

    Make sure the sprite is invisible, but has box collision detection and resize it to the shoulder-width of the zombie (or smaller for finer detection). Then set the centre of the detector to its parent zombie, and stretch it to the player.

    If it doesn't overlap a wall while overlapping the player, it can see them. Might be handy to put a distance check in as well to ensure the player isn't miles away if you want.

    Anyway, I hope it works =]

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You just solved my problem. I had never heard of containers but it seems like a logical idea. Imma give it a shot in the morning and see what I can come up with.

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