Crowd Simulation Progress

(snot_nose) #1


I started to develop a crowd simulator with blender’s game engine.
after working with 3dsmax biped crowd simulator, i noticed that the crowd simulator is basically very similar to a game engine.
I’m currently developing it for the cockroaches in the open source short film ‘Tube’ , there is also the crowd sim from josh that will be used, which is more based on particle systems.
you can download the blend file from HERE
and the python script from HERE
Right now i finished the first step of the Crowd sim, which they need to avoid each other, and have a target. the yellow group need to get to the orange box and the green group need to get to the blue box.
I can write more explantion about the AI if people are interested but you can also just check the python script.
the next thing i need to work on is climbing system, so that the cockroaches climb on some objects.
after that i will make some objects that will trigger them, like something that will fall and make them run away using the near sensor.
It’s my first script with python, so i would really appreciate if people can have a look on it and give advices or ask questions, I had some problems with python like setting up some variables for the movement (my) for example. instead, I had to use the object property to set it up, but i don’t really need it as a property just variable that change all the time in python.

actually it’s not exactly my first script, I started to build the crowd sim with character from my work (I work as character animator in video game company so I already had all the clips like walk, run, turn left, turn right, idle…) you can check the old version of the sim here
but it’s without the characters since I don’t “own” them i couldn’t upload them as well. the main difference is that the characters have 2 different turning modes, one is bending and the other turn exactly 90 degrees with f-curve and then the character was using turn left or right clip.
in the current version the use only motion actuator for turning, and they are a little bit smarter

here is some problems I’m still facing (with the current sim):

  • when you open the current version of the simulation there is 2 scenes. if you go into scene2, you can see that i build kind of a small maze for the cube that need to get out, well, it doesn’t. at some point it get stuck with endless turning, and this i guess i will solve with the timer.
    I’m assuming that it’s conflicting with the target trackTo and also mainly the near distance is conflicting with the far distance radar. I still didn’t manage to solve it

  • Recording, somehow i can record the cubes only on 60 fps. does any1 have an idea why? is it possible to record on other frame rates.
    also another MAIN problem is to record armatures animations, if there would be a way to cache the animations, or even better, getting it into NLA clips, then i think we will cross a big bridge from the game engine into the crowd sim.

  • A good crowd sim could also go backward in the sim to look for new solutions when he get stuck, I guess this would be completely into the game engine and changing it. it could be cool, but i guess i will just need to settle down on a good AI for my boxes.

the objects have priorities that also affect on their behaviors.
Could be cool also to write a script that give them automatically priorities for the objects, but before starting the simulation, so i can still alter them, right now i need to give priorities one by one.

in the end i would like to make it somehow user friendly. with some interface or maybe at least to use the object properties as the interface.

if there is people that could help somehow with this project, then fill free to join aboard. I guess right now the main thing I could use is the armature recording.

(snot_nose) #2

maybe a video sample is more attractive, even if it’s just cubes moving around right now :wink:

since there is also randomness function, every simulation will be a bit different…

(John_tgh) #3

Hmmm… pretty cool, reminds me of a vertex based script that was made some time ago. You might find some use for it…I’ll see if I can find it.

(snot_nose) #4

here is a new updated.
This time they are also climbing on objects with ‘wall’ property

here is the source files - (overwrited on the old one from the post before)
and the blend file

the python file is still a bit messy but i will organise it more, will be happy to get some advices from people since it’s the first time I’m using python

Still got issues to solve:
-Corners with 3 axis (the top corners of the climbing objects), right now i solve it with putting and object that will avoid them reaching this point, and for now I’m satisfied with this point.
-when they walk on the side of the cylinder they can walk only through half and after they are ‘flipping out’, right now it’s solved again with just avoiding objects
-at some situations when they climb and rotate on to the top face, if there is too much objects/conflicts up already they can also ‘flip out’ at some situations.
-when they are climbing/going up the track to actuator is being turned off, since it creates a conflict and force them to point downward to the target (maybe i just need to create another target upward that they will use while climbing…)

  • and most important still need to find a solution for recording the armature animations after i will connect the cockroach characters to them. any ideas from someone?
    does any1 know if maybe instead of recording, it’s possible also to control the movement after with a script that tell them which action clip to run depend on the movement of the collision boxes?

I think next step i will already start to implement it in the tube project
will be happy for some advices and comments

(snot_nose) #5

and here is the (currently) final simulation implemented in the open source film - ‘tube’:

current tube version:

Slower version so you can understand more the behaviors:

there is still no animation, no cracks in the floor and the roach objects are just references, right now it’s only about AI!
I’ll be doing a presentation with more samples at the Blender conference - Amsterdam!

(wysiwyg) #6

I’ll be doing a presentation with more samples at the Blender conference - Amsterdam!

that should get you a lot of attention! its odd that no one has commented, i would think this would be very enthusiastically received…i hope it will!
hows tube? havent seen any updates in a while…is there a release date planned?

(leonnn) #7

Very intresting snot, this is pretty cool!

(C.A.ligári) #8

New to the Forum and 'til now only lingering around in the Game Engine Corner I was not aware of this Project. I am astonished by the Art Style of you Guys, and I really can associate with the Style pretty much (being an Artist myself)!
Might have been a Bit off-topic right now, since I am of no Use concerning your Crowd Simulator.
Though I feel I must and want to keep an Eye on that Project, even if I do not know what it is about (story-/theme-wise), since it’s got that fancy Art Style! : D

Post Skriptum:
Strangely the Character on most of your Concepts has similar proportional Elements to the Nephilim-Character on my Profile Picture – hell yeah. \o/

(snot_nose) #9

Thanks for feedbacks.
About tube - I don’t think there is a release date planned.
Since it’s mostly voluntary work and it’s aimed at high quality with very specific style, I’m not sure that it is even possible to know.
I know that there were a lot character animators joining now, and I think most of the models are complete, so i guess it’s gonna start running now…
I also did one shot of character animation to gilga if you are interested to see

(C.A.ligári) #10

Good Shot, I like the Animation. : )
You Guys are inspiring me. I think I’m gonna take a little Break from the Game Engine – already got a lil’ Shortmovie Storyboard lying around here (right under my Laptop, strangely). It’s really getting Time I do something with that one, even if it was originally intended to become a Stop Motion Movie…

(snot_nose) #11

new updates:
more crowd simulation

and another shot, everything is still WIP:

  • still no animation (except for the roaches in the foreground in #3), only AI. we ran into ‘issues’ when we try to use the ‘autowalker’ script.
  • I did the crowd sim presentation, and it got some interest, and might get some help from developers, to develop it further.
    the presentation will probably get online.
  • there is a new actuator since 2.6 called ‘steering actuator’ together with some other new tools, like navigation mesh. it seems like it’s doing most of what i scripted already. so building crowds is defiantly going to become easier.

ideas for further development:

-The recorder should be fixed, right now it’s recording only
on 60 fps, also the action actuator doesn’t work properly with
the recorder.

Giving some more options for the recorder could be helpful.
For example:
Enabling recording of armature actions could push this
project much forward.

Right now we are going to use the autowalker script, but for
more complex creatures we could add much more behaviors
then walking and stopping actions.
Animated armature actions would be activated by the action
actuator and conditioned with python.

-Creating foot system for characters, to avoid sliding for walk

-Adjusting parallel properties and values for multiple

-Making the crowd system built-in blender’s game engine, or as an add-on, the
new steering actuator is already a big step forward.

-Creating more connections between different editors could
make blender stronger and with more options to be
developed. For example connecting the game engine into the
particle system and node editor.

(leonnn) #12

Very nice, i really liked it!

(bankbaa) #13

Oh I really want to see some war scene can you make war with this sim.

(snot_nose) #14

Autowalk update

the animation was done using auto-walk script, which was re-written and rigged by Bassam Kurdali (Director and Technical Director of Tube), based on the 2.49 ant rig by MCHammond.
Bassam also built an interface that gives a lot of control over the roaches.
Frontal and background animation by Karen Webb.

Bankbaa I think it’s still a problem to do setup war simulation, especially because i couldn’t get the recorder to record bone armatures.
only the control boxes for the characters. the good news now is that the steering actuator and navigation mesh can make it much easier now to build the AI for path finding and obstacle avoidance.

(nitrofreak06) #15

That is really amazing. Keep up the great work!

(gianmichele) #16

This looks really nice !!! Can’t wait to put my hand on one of those roaches