Enemy Platform Behavior Questions

Get help using Construct 2

Post » Mon Apr 09, 2012 7:21 am

I've spent quite a few hours looking through the forums and tutorials tonight, but I haven't been able to wrap my head around these 2 issues:

1) As a side-scrolling platform game, how would you have the enemy shoot at you when you are above or below them on a different platform (and detect that you are)? I'm looking for something realistic, where they are actually visibly aiming at you in the proper direction as they fire.

2) How do you spawn multiple enemies of the same type, but have them act out the same enemy type events independently? (attack at different times, die, detect player, etc.).

The examples I have found had all enemies performing the same actions at once, or they had independent events for each instance of a monster; both solutions will not work for my situation.

My skills are fairly amateur, if you can help me out with a capx file; that would be amazing. Thanks!
B
3
Posts: 14
Reputation: 453

Post » Mon Apr 09, 2012 11:54 am

Some general thoughts:

Making generalized "A.I." is not a good idea. That's why "A.I." is done in most cases at the end of game production cycle. At least not before you know some specific things about your game world. You can't solve (compute) problem-situation if you don't know anything about it (no input). With all of your major game word elements known, you can make number of "hacks" - cheating to make enemies look intelligent - it doesn't matter if enemies are intelligent or not, as long as they look smart (that is player doesn't notice cheating) - in games it is all about surface (designers of A.I. for Halo noticed that during playtesting faze making enemies little bit harder -more hit points to kill them - cause playtesters to perceive them as smarter). There is lots of little cosmetic things that you can do to make enemies look more "intelligent" (provide the
player with some visual/auditory clues as to what the agent is thinking about: different animation of enemies when player enter enemies' FOV and some audio information- "Aha!", "There you are" - when it exit - "Where is gone"...)

Unknowns:

1) How would you move your enemies - platform movement can be done in many ways in C2( physic, platform, and custom behavior, or even via events). And how would enemy perceive game world (visual and/or audio).
   2) Previous determines possible ways of how would you calculate desired trajectories to satisfy the
        3) Goal - Search, Follow, Attack, Hide... Don't make enemies react instant on single parameter - if Value A then action A. Make group of conditions for single goal - Attack: is in FOV, is in Fire.Range, is Enemy.Energie greater... than on Goal.Atack: move, shoot...And this requires
             4) Logic for switching from one state/goal to another.

oh... i carried away



Your problems:


Question 1

For basic AI "vision senses" you need distance form player, angle(Player, Enemy),is in angle(Player,Enemy) range, and is line between player and enemy overlapping obstacle
Look at this examples:
A) http://www.scirra.com/forum/c2enemy-line-of-sight_topic45095.html
http://www.scirra.com/forum/enemy-ai-los-line-of-sight-engine-c2_topic46730.html
B)http://www.scirra.com/forum/turrets_topic49010.html

Examples A will tell you if is player inside of enemies in line of sight, and example B will tell you how to make "realistic" cone of view. Try to understand them and combine them.
Suggestion: If player is in enemies FOV for short period and then exit it, you can create object LastPosition on that place and make enemy go to LastPosition (otherwise enemy would act as he dont care for Player unles Player is in FOV). You can make some private variables in Enemy - LastPositionX, LastPositionY (when Player leaves FOV set them to Player.X, Player.Y). You can even store Players VelocityX, VelocityY, and Speed at point of exiting enemies FOV and predict possible new position after second or so, and than spawn another object there and tell enemy to go and look is it player there or not. This is all pretty simple but you can get with it decent enemy behavior.

Question 2

It is not clear to me what you exactly think. Do you think intstances of same type (Sprite) - instances dont react all at same time unless you tell them to do so. If you specify conditions for actions and include "for each", then only instance that satisfy those conditions would be picked and perform those actions.
Or you want to make Global.Enemy type object (one logic for all enemies) and then send to him specifics of each type ("different attack times, die, detect player"). For this you need families and families behaviors implemented. Wait and learn what is there.podpathos2012-04-09 15:49:45
B
12
S
2
G
2
Posts: 96
Reputation: 1,583

Post » Thu Apr 12, 2012 3:55 am

Thanks for the links.

I intentionally left my post vague, it was not due to lack of knowledge of the basic fundamentals of game design or theory. I did not want to sway my general inquiry by focusing the answers around specific details. I'm strictly prototyping at the moment, I'm not looking for polish. I should have specified that.

As a bit of background, I've actually worked on about two dozen games over the last 6 years, from a design/production standpoint. I'm well aware of the flow of implementing AI into a conventional game. It might surprise you to know that our AI programmers almost never actually launched the game or level environments. Most of their code work was performed in a simple cube environment with very few static meshes. I've never seen AI done at the end of a games lifecycle; although, I imagine each studio has their own approach. I'm only speaking from the perspective of 4 studios I've been involved with.

Minor tweaks to fake intelligence happen throughout the project, it's largely trial and error. You don't implement AI at the end of a project, it is the most time consuming aspect of most projects. You want your design and test team working with functional AI behaviour from the earliest point you can establish. In fact, most of the level design workflow was designed around the functionality of the AI; not the other way around.

I have to emphatically disagree with that Halo example. Making your enemies take more damage will end up making your enemies look dumb, not smarter. It is a horrible attempt to cover up how inadequate your AI is at self-preservation. Smarter AI should be able to survive in scenarios where they could die with a single shot. You should see games like Stalker or Killzone 2 (on hard difficulties), especially their tech demos. Another indicator of covering up bad AI is when you have different enemy types who have limited behaviour; instead of giving AI that can intelligently transfer between multiple behaviours. Quantity doesn't make up for lack of quality.

Most of the rules of traditional games fly out the window in a simplistic platformer, when you are limited to 100 events (I'm evaluating the engine for a personal project). A key reason why I never once used the word AI in my post, was because I'm not concerned with making them appear intelligent at the moment. I hope this post helps clear things up. I'm well aware of the direction of my intended project and have fleshed out exactly how I want my enemies to react in almost absurd detail; most of which is fairly out of the scope for my prototyping.

1) I was more concerned with how you would physically handle the act of having your enemies fire upwards or downwards. Would you pin their torso/arm and have them automatically face towards the player? Is a better solution to have animations for each enemy where they face upwards or downwards? My question was more centered around handling the sprite, not so much the reasoning behind why they are facing the user. Although, I'd gladly take advice behind engine tips for that as well.

2) As for the second question, the "for each" answer was what I was looking to find out about. I didn't know the engine had the ability to specify it that easily.

Thanks again!PaulStrife2012-04-12 03:56:47
B
3
Posts: 14
Reputation: 453

Post » Thu Apr 12, 2012 5:39 am

I was mislead by "realistic" "visibility" "detection", and when I think of some kind of "A.I." in CC or C2 I don't go beyond simple FSM (that is Quake 2 - single player enemies not bots-, pre 2000 - where in action games AI is something you devote smallest part of production time), but I didn't said is always done at the end, I said that you must know some basic elements of your game world (which you didn't specify and I was thinking that you want to make AI) - that's why "Most of their code work was performed in a simple cube environment with very few static meshes", knowing what inputs they can get and how game logic functions. I leave discussion about A.I. alone.

For realistic aiming I think is better to have separate body parts - legs (animated), torso, hands and head attached and controlled via events depending of angle between target and enemy and/or some other conditions.

There is Lucid's (forum member) amazing tool Spriter, he may implement in Spriter procedural animation - which can be controlled via events, like in this example he made in CC: http://www.youtube.com/watch?v=56TYzcFerPw

try beta: http://brashmonkey.com/

see possible future features: http://www.kickstarter.com/projects/539087245/spriter?ref=live



edit: one more thing I didn't say about question 2. If you use private variable for (attack time, die...) each instance would behave on their on - update according to its actual state (of energie, position...)podpathos2012-04-12 11:16:00
B
12
S
2
G
2
Posts: 96
Reputation: 1,583

Post » Thu Apr 12, 2012 12:08 pm

Here is one possible way to do what you want...It is character from game Abuse(legs and torso animation), and I made it as Player character but you can figure out from here how to make it enemy (instead of sight it would be player)...also image point from which bullet spawns is not correct....

capx
B
12
S
2
G
2
Posts: 96
Reputation: 1,583

Post » Sun Apr 22, 2012 2:25 am

Thanks for the direction, it definitely will help.
B
3
Posts: 14
Reputation: 453


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 17 guests