Download

Time controlled NPC actions

Hey guys,

I´d like to give my NPCs a bit more “personality” and make them do things at a certain time of day.

NPC Mister X : 8:00 → go to workstation A , 12:00 → have lunch, 22:00 → go to the sleeping area
NPC Mister Y : 7:00 → go to workstation B , 11:30 → have lunch, 23:00 → go to bed
etc.

I´m not very experienced in AI programming in UE4. The only tutorials I could find were simple chase player, shoot at player, follow player actions, etc. but not really more complicated stuff. How would I organize time based actions for multiple NPCs and how could I trigger the different actions?

Best,
Michael

I haven’t done it with UE4 yet, so I’m not sure how helpful this will be to you but I imagine you would have some sort of timer always running in the level (the time of day) which you use to trigger AI actions every so often. The way I did it on another very limited engine was simply incrementing a number based on frames per second haha. This number was then saved across levels. I’m sure UE has a better way. It helps if you can convert the number to something readable you can use for scripting.

Though scripting NPC routines can get messy, especially when you’re doing it for the first time. So many bugs can creep in… especially when adding features like loitering (from elder scrolls/fallout series) and changing levels etc.

Thanks, Roden for you reply. I have got a time variable from my day-night-cycle.

Anybody else with a bit more technical advise on AI “blueprinting” certain actions triggered by time of day?