Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Entity crowd behavior

Author
Message
Quel
17
Years of Service
User Offline
Joined: 13th Mar 2009
Location:
Posted: 28th Aug 2014 15:28 Edited at: 28th Aug 2014 17:44
I've been working on and off on a Herzog Zwei sequel since 2012 January.

It's been canned for a few months up until recently, when i rediscovered my pathfinding attempts, that inspired me to develop it into a quite advanced state, and i'm practically at the point where i mostly only have to worry about the entities colliding with each other.

After giving it much thought from a "recalculate every time a collision occurs" perspective, i came up with the idea for them to simply push each other out of the way whenever possible. Sure can lead to some funny moments, but functionality is my preference.

And of course, it can be set so tanks toss away infantry easily, while it's not the case in reverse.

Obviously i immediately jumped into a 'big loop with tens of thousands of distance checking' solution, and had to quickly realize that won't work on a big scale. Started to optimize it, putting in delays, and so on. But performance just slowly increased while the units started to act funnier and funnier.

So i dropped the noobish way, and this is the result, please have a try. There's one entity out of the thousand, that follows your cursor's position.

I'm very satisfied with it, it's set to a 1000 entities, and gives me a stable 114fps. I'm not even sure if more than 200-300 units will be in the game at once...

You can see how fast it really is if you push Space, it hides the circles, and show the fps with only the calculations.

What fps do you guys get?

How would YOU solve this crowd simulation problem?
Derek Darkly
14
Years of Service
User Offline
Joined: 22nd Sep 2011
Location: Whats Our Vector, Victor?
Posted: 28th Aug 2014 16:00
I haven't implemented this into a game yet, but what I did was perform distance checks and then instead of having the entities push each other, I had them try to rotate away from each other just enough to create some "elbow room."

(This may not be the behavior you want)



666GO†O666
Quel
17
Years of Service
User Offline
Joined: 13th Mar 2009
Location:
Posted: 28th Aug 2014 16:24 Edited at: 28th Aug 2014 17:26
I find the concept of pushing each other the best since that will in almost every case result in a gap even in the most crowded environment for the unit that wants to follow its path. And even if an entity gets pushed out real far from its original place, it can return to it once no more push is being detected using pathfinding.

Besides, calculations for pushing away is extremely simple.
Derek Darkly
14
Years of Service
User Offline
Joined: 22nd Sep 2011
Location: Whats Our Vector, Victor?
Posted: 29th Aug 2014 02:18 Edited at: 29th Aug 2014 02:21
Quote: "I find the concept of pushing each other the best since that will in almost every case result in a gap"


For all I know that's what other developers do also.

However... I don't think it would look very realistic in certain cases. For example, if 2 tanks collided in the real world, one certainly wouldn't just slide the other one out of the way. Not as if they were on ice, anyway.

Real crowds usually involve a lot of strafing motions and turning this way and that, no? I love playing Skyrim, but hate it when my character gets pushed and it looks like he's on ice. They could have made him stagger at least!

Anyway, to each his own. I'm just glad to see people making games. There aren't enough fun demos, etc. to play lately!

666GO†O666
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 29th Aug 2014 04:21
Quel
17
Years of Service
User Offline
Joined: 13th Mar 2009
Location:
Posted: 29th Aug 2014 10:06
Thanks for that link Comet, although that demo gives quite silly results.

Well of course members in a crowd of people could show some staggering animation while being pushed away, but it's not hopeless in the case of tanks either to reach a more realistic picture.

They sense that a moving object has come into them, so they would turn the exact opposite angle (or towards... since they can go backwards as well... which is closer to turn to), and then started to slide, it would look like they use pathfinding.

It was already worth starting this thread, i may have just did it with mindless sliding all the time!

I'm working on making it even more efficient, and to support collision with map walls and different unit sizes, then to implement it into my pathfinding module, then it will be up for you to test.
Quel
17
Years of Service
User Offline
Joined: 13th Mar 2009
Location:
Posted: 29th Aug 2014 14:22
By the way, has anybody even noticed that this topic isn't a desperate cry for help, but a demonstration of my working method in action, and an asking for feedback on it?
Quel
17
Years of Service
User Offline
Joined: 13th Mar 2009
Location:
Posted: 31st Aug 2014 12:47
Here's the updated version, with some silly excessive calculation taken out that also produced strange behavior from time to time, and i also introduced some space between units, there is collision with map walls, and different types of different unit sizes with their own mass values (this one is not very apparent since i set the mouse unit to the largest).

If you experience any serious looking bugs please let me know.

Login to post a reply

Server time is: 2026-07-05 13:58:04
Your offset time is: 2026-07-05 13:58:04