Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411492 Posts in 69377 Topics- by 58433 Members - Latest Member: Bohdan_Zoshchenko

April 29, 2024, 07:24:12 AM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)basic 2D platformer AI question
Pages: [1]
Print
Author Topic: basic 2D platformer AI question  (Read 4447 times)
György Straub
Level 4
****


Friendly Giant Nano


View Profile WWW
« on: September 11, 2008, 12:14:35 AM »

I'm just about to timidly cross the border between framework development and game development, with one toe. Trying to test the cooperation between Camera and Collider classes I was going to do a quick 2D platformer sketch, then a somewhat related realization hit me: how the hell am I going to check for platform edges in the enemies' AI, preventing them to fall off the edges? The "game" isn't tile based, it's polygons.

I was thinking that during collision detection (which, as I see it from here, will be done with different groups (std::list-s) of game objects), I'll just check the collision normal from an enemy-wall collision, see if it's that of a walkable surface (<45° (normal.y > normal.x -- as it's perpendicular to the surface)), then check the length, do some offset magic (relative positions) and use that to see how far can the enemy walk.

yes, it does get blurry towards the end...

I guess it isn't even strictly AI. All I've found is Game Maker stuff (.gmk files...) and GameDev.net's AI resources (this was and is going to be useful, just not for this problem)...  has anyone seen anything on the interwebs that might just have to do with what I'm trying to do?
Logged

Dacke
Level 10
*****



View Profile
« Reply #1 on: September 11, 2008, 12:18:24 AM »

Manually setting up walking zones for every individual?  :D
Logged

programming • free software
animal liberation • veganism
anarcho-communism • intersectionality • feminism
bateleur
Level 10
*****



View Profile
« Reply #2 on: September 11, 2008, 12:53:56 AM »

how the hell am I going to check for platform edges in the enemies' AI

I'm not sure what the best way to do this is, but one possible approach is to have an invisible sensor in the direction of the enemy's motion which uses the same movement rules it does. It then provides feedback to the enemy's behaviour. So on a simple level "Oh poop, I've walked over a cliff" is interpreted as an instruction to turn around.

This approach has the advantage that you can later make the enemies smarter by having them respond to different upcoming problems in different ways.
Logged

X-Tender
Level 1
*



View Profile WWW
« Reply #3 on: September 11, 2008, 12:58:59 AM »

Tahts the same suggestion I wanted to post Smiley
That you handle your enemy like taking a dog for a walk.
Its hanging on the leash from the invisible man that walks in front of him and he try to reach him.
Logged

György Straub
Level 4
****


Friendly Giant Nano


View Profile WWW
« Reply #4 on: September 11, 2008, 01:26:05 AM »

awesome! thanks guys, especially bataleur.=) so, if I get it right, I should be checking for a LACK of collisions in front and below the enemy?

w for wall, bold for entities, italic for the "phantom"
p  <-e
wwwweww
wwww ww



/I kinda like the walking zones technique too, but it involves storing information that can be redundant or wrong at times (with respect to falling down - like if the player blows a hole into the path of the enemy (even worse if it happens while they can "see" it))./
Logged

Dacke
Level 10
*****



View Profile
« Reply #5 on: September 11, 2008, 01:44:48 AM »

Indeed. Even though I was mostly joking, it is quite possible to incorporate different invisible enemy-command-blocks into the level design. It can allow pretty complex enemy behaviour as each enemy can get different instructions based on where it is. It however requires a silly amount of extra work and can get pretty messy and is probably bug-prone.

The invisible man, however, sounds like a very general and nice solution. As changes in a character affects it's invisible man as well, behaviour will stay stable even if you make big changes.
Logged

programming • free software
animal liberation • veganism
anarcho-communism • intersectionality • feminism
Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic