Simulating pedestrians

I’m looking into something new: adding pedestrians into my scenes! Seems easy…and I have had some limited success. But I’m not sure if I’m doing it right. I have seen several tutorials/examples of different ways to control AI characters, but nothing has “clicked” yet.
Here’s what I want my pedestrian to do:
I want to place the pedestrian in the scene
I then want to select an array of way-points for that pedestrian to use.
I want the pedestrian to follow those points.
If a way-point is set to “don’t walk” (like at a cross walk), the pedestrian needs to wait. When the “walk” is enabled, then the pedestrian can proceed through the rest of the way-points.

This is delving into stuff I’m pretty new at with UE4.
I would like to do this 100% with blueprints.
Any advice or link to a tutorial that has an example of this would be appreciated.


I’m also interested in this area after devoting a lot of time to crowds, animations and flocking in UDK, only to find they’ve been dropped in UE4…

There shouldn’t be any problem in doing this with behavior trees and navmesh. You will just want to throw a trigger volume at the crosswalk that toggles a blackboard variable to make them wait until the variable changes when your light turns green. A lot of behavior tree tutorials around on youtube that should cover 95% of what you need.

There is also a good open sourced project that has been done on here for boids and flocking AI that works independent of navmesh which you could work with too. Examples he has in the project are with fish and last I checked he had been working on a sheep example too which should relate more closely to what you want.

Interesting… Any Links?

maybe he’s referring to THIS thread.
It’s a little hard to follow for the beginner. I’m having a small issue with just wrapping my head around the concept of how this works. It’s STARTING to click…but not quite there.
It seems the examples and tutorials kinda focus on something different than what I’m after.
But, from what I am getting out of this so far, I really need a behavior tree that has only two tasks (walk and wait). I need a set of waypoints that my pedestrians cycle through. If they overlap the “stop area” trigger volume and it’s set to “don’t walk”, they’ll do the “wait” task. If the trigger volume is set to “walk”, they’ll just go to the next way point. I just need to figure out which set of waypoints the bot will follow and which direction (think of an intersection with sidewalks and crosswalks and all the different ways pedestrians would go.
Seems easy…but it is just not clicking for me. I’ll keep plugging away at it:)

Yup. Still stumped. I’ve tried a couple of tutorials, but they don’t really hit on what I’m after and they seem targeted to a single AI bot. I’m not sure if it’d work with multiple bots.
I’ve tried with Blueprints (with better success, but still missing the mark). I can cycle through waypoints just fine, but can’t figure out how to check the “stop areas” all at the same time. I was using arrays for the way points and for the stop areas.
I have 3 volumes per stop area. One that checks if we’re in the stop area, one that checks if we’re on the street side and one that checks if we’re in the sidewalk side (we don’t want pedestrians stopping when the don’t walk sign is on if they are finishing crossing the street). So lost…
Any clues?

That’s the flocking AI that I was referring to. For something that is talking about a single AI bot it shouldn’t matter since you are referencing each AI actor and they will all follow the same behavior tree but each will be independent of each other.

In your behavior tree you will want to check for those variables as a blackboard key. So you need to set the blackboard key when they hit those overlaps. Just have a check on the behavior tree for if those are true and then jump to the next step in the sequence which would be a wait command until the key changes. You will need a couple of different keys to check if they are already across the road or not, and more advanced you would put a timer on the lights changing and make the AI figure out if it’s got enough time to cross the road before going.

I’m trying to make this as simple as possible…because I’m not a coder.
So I’m trying blueprints.
Here’s what I have:
BP_StopArea: This has a simple counter. It counts up every second. When it reaches a specified time, the light turns to “don’t walk” and a “DontWalk” boolean is set to true. The counter resets and counts to another specified time, then sets the light to green and “DontWalk” to false.
The BP_StopArea has 3 volumes: OnTheSidewalk, StopArea, and InTheStreet (these are used on the Bot for conditions)

My PedestrianBot starts by binding overlap events from the different volumes on the StopArea blueprint.

Then, the pedestrian moves through the waypoints, checking if it needs to stop or not. It check: DontWalk (from the StopArea blueprint). If it’s false, it just keeps moving. If true, are we in the stop area? (no=keep moving). If true, are we in the street? (if true, keep moving…we don’t want to stop in the street). From there, a counter steps through the array of way points. But this is the meat of the movement choices.

This works! Well, it works for ONE Pedestrian Bot in the scene. If I put another one in, apparently the overlaps aren’t unique to each specific Bot. In other words, if one stops, they all stop. So, when Pedestrian_Bot_01 reaches the StopArea, it gets the overlap events and does its thing. When Pedestrian_Bot_02 is still walking down the sidewalk, it receives the overlap events from Pedestrian_Bot_01. Why is this? I thought the BP’s would behave independently?

It looks like you have over complicated it quite a bit actually. I don’t have time at the moment to build out an example for you but I might give it a go next week as it’s something probably fairly useful to people. You will want to check that you are using the correct structure for Behavior trees and AI controllers and pawns. It seems like you are potentially setting and checking variables in the wrong spot.

If you want to upload your project to Drive or something I will check it out and see if I can help with your current build.