here's what i meant:
here's what i meant:
This is starting to become a really solid example of zombie AI I think and a huge help! Is it possible you, MuddyMole or someone else could put in some comments in the events of what the events do? I want to study this and learn it so I can work from all this later and know what is actually going as I have never done these kinds of movements or events before and need to really try to learn it inside out.
The only obvious thing I see missing now is a good way to adjust the "layering" of the zombies on the fly so that the ones that have the greatest Y cordinate are in front of the ones with the lesser Y cordinate. What would be the best method to do this? Should the layer object be used for it, or is that unnecessary?
I guess it could be done with just running a constant fastloop for every Y cordinate from top to bottom and then if it finds a zombie at that Y cordinate it puts it in the front, but that sounds really slow for performance and not an optimal method?
To be honest, there's a LOT that could be changed to make it smoother and less buggy, but it was really just to demonstrate the basic idea.
And yes, the layer object is your best bet for sorting, even though it's not great.
Oh, I never meant to leave that extension there (was just checking something).
Well, it's really more a lot of ideas that could be tried - some of which might help; some of which might make it worse...
For example, I've been experimenting a bit with collision-detection between circles and map tiles (stored in an array), using maths rather than any built-in method. It's pretty maths-heavy, but the nice thing about it, is that you can find the precise point at which they collide, which could be useful in various ways. For example, you could easily get the surface normal, to make the zombie turn the right way to avoid walls (or for making objects bounce realistically off walls). You could also take the distance into account when prioritising zombie behaviours - so if a zombie is very close to a wall, avoiding the wall will be its top priority; if it's a little further away, avoiding the wall and avoiding other zombies will have equal priority; if it's very far away, avoiding zombies and moving towards the player will be top priorities.
As I said before, I'd try to create vectors representing various "forces" that determine where a zombie moves, and then multiply them by their priority rating, before adding them all up to get a final movement vector.
- VectorAwayFromZombie (one vector for each nearby zombie)
That part should be relatively easy as long as you have a reasonable grasp of vectors (eg. know what a unit vector is, how to find the length of a vector, how to multiply a vector by a scalar, etc).
As for the Layer Object, would just an always event that sort by Decreasing Y do it? It works, but not sure if there is a better way to do it?