The Daily Click ::. Forums ::. Klik Coding Help ::. Platform movement AI troubles

Post Reply  Post Oekaki 

Posted By Message



VIP MemberI am an April Fool
4th July, 2009 at 03:06:35 -

There exists no example of working platform AI as far as I know. I have combed through the threads and articles here with no such luck. I only want something basic. Each enemy has a set area where they walk back and forth, stopping occasionally. When the player is in their range of sight, they will walk in the direction of the player. If they reach the end of their patrol zone, they should stop and look in the direction of the player. If the player returns to their area, they will again walk in the direction of the player, otherwise continue their patrol. Thus far, I have had no luck with making this work. I am new to fastloops and spread values and am not sure how properly implement them. I can get each enemy to have their own hitbox and detectors of sight(not the best way, I know) but no matter how many exceptions I put in, enemies always do the same thing no matter if the player is next to them or not. Does anyone have any simple platform AI example? I imagine this is one of the simplest platform AI you could put in a game as the enemies do not need to track the player outside their own area.

Any help would be much appreciated and credited.




VIP Member
4th July, 2009 at 03:50:58 -

Do this:
Spread value 1 in alterable value A of enemy (this will ensure that only the enemy within range will be affected)
(alterable values are internal to each seperate instance of the same active which allows this to be possible)

Character/player is within range (use something like x of player > x of enemy -50 and x of player < x of enemy + 50 to find the range)
and Enemy is within range of character/player (x of enemy > x of player -50 and x of enemy < x of player + 50)
---> Set alterable value A of character/player to the alterable value A of enemy

If Alterable Value A of enemy = Alterable Value of character/player
and Alterable Value A of character/player = Alterable Value A of enemy
---> Set enemy attack sequence into motion

Of course you'll need to figure out the simple moving the enemy back and forth AI, or whatever sort of initial walking the rounds guard duty type movement you want before adding the above events.
(the reason that I've included things that may seem redundant btw, is in hopes that it makes it specific enough to work without flaw)
This is all only a guess of course because I have not tested it myself having not ventured into the realm of AI yet.
To me AI seems like it could be fun though, and not difficult until you get into advanced features and crazy mathematics.
Like I said though, this is coming from a simple logical guess as to how it may work, so it could fail, just gotta try it in order to see I guess.
If it doesn't work with all those events, try deleting some and/or switching things around a bit, sometimes that helps.

Click Me!

Blood of the Ancient One, Seen only as Shadow, Faster than Lightning, Fierce as the Greatest Dragon, Nearly Invisible, Floating in a Dream, Entered through the Demon Door, Destroyer of Evil in a Realm with a Red Sky Scarred, Who could I be ?


of DringleTopia

4th July, 2009 at 18:33:35 -

You might also want to have a look at the Zeb game that comes with MMF, it has NPCs that behave similarly.

Edited by CodeCannon



4th July, 2009 at 19:40:36 -

I made an example of some platform AI, give me a while to find it. But yeah, look at Zeb and such.

I am no longer not a taco.

Post Reply



Worth A Click