Events are interrupts but in a make believe comp-sci context

Had a few learning experiences with Unreal when working on the global game mode settings stuff (Also I used the term “group ID” in the game but I call it “team ID” randomly so bare with me here and assume they’re the same thing).

1 – Event dispatchers kick off before the game tick (which I really should’ve known from the start).

If you’re interested in what I mean by event dispatchers see (https://dev.epicgames.com/documentation/en-us/unreal-engine/event-dispatchers-in-unreal-engine)
The way I have the transfer from the terminal originally setup was:

  1. Player presses transfer button, the transfer completes which triggers an event dispatch call from the terminal

  2. The terminal alerts the assemblers connected that the team has changed
  3. The assembler flips the team ID’s of the bots and alerts the game mode via another event dispatch call
  4. The game mode (which is bound to all team ID change events) receives the event call and then alerts all of the assemblers the last location of the target
  5. Then all of the assemblers get the direct call to alert their bots to a new target
  6. The bots then get the alert for the new target

The problem started at step 3. The way I setup the patrol bots was that they would essentially copy their state from the actor into the control, then into the blackboard (see https://dev.epicgames.com/documentation/en-us/unreal-engine/behavior-tree-in-unreal-engine—quick-start-guide ) every tick (which is horrible and I need to fix. The controller should own the pawn and the pawn should be only relaying sensor-ish info back to the controller). In addition the way team swapping works on the patrol bot is that the bot will end it’s current engagement, then flip its internal team variable. Finally the patrol bot is alerted while its engaged it will NOT change its current target and will continue the engagement.

So the problem with that is that Steps 4-6 would execute before the next tick after step 3. Therefore the bot was alerted BEFORE it stopped its engagement and ignored the new target location. So from the game perspective the bot would stop what it’s doing then start walking to the last player location that was reported by the bots. The reason 4-6 executed is because it was a chain of event dispatches that lead to a function call. If I wasn’t using blueprints I probably would have gotten a segfault, however in this case what happened is that the tick was delayed until the event was finished.

This was fixed by changing how the controller worked so that when you get an event that stops the engagement you flip the value in the blackboard on the same chain that changed the team id. Therefore when the alert comes along the patrol bot is not engaged and the new target location is updated accordingly.


2-The there’s two functions to get a reachable point within a circle on the nav mesh and the one that works changes upon the context:
– Random Reachable Point In Radius – When you’re in an actor
– Random Location In navigable radius – When you’re calling from an AI task

I had the 2nd one swapped for the enemies so the only thing that would get a valid location was something directly on the nav mesh. I didn’t notice until I stopped putting stuff right where I wanted the bots to move to.

OTHER STUFF

Also I added a placeholder for the thing the player needs to destroy called

THE DEATH BOX


Which is just a box with health and a teamid.

This is the thing that gets targeted once the assembler gets its group id changed. There’s some other stuff I poked at, the AI had issues which I touched up. Difficulty gets set and propagated through the game mode down to the assemblers which sets the bot types and quantity.

Generally the bare bones “Game” part is working, I need to make a kill screen but basically we’re looking good. Here’s like 2ish minutes of gameplay (I had music playing from abelton while this was going but it wasn’t captured for some reason, abelton might have winsound trickery happening in the background…or obs isn’t as great as I thought) so its kinda quiet. But things to look out for:
1.) I start, the bots are shooting at me. I press the transfer button, the bots stop shooting at me and start walking towards the death box
2.) I press transfer on the second console and the transfer bar comes up and finishes, which causes nearby bots to stat shooting at the death box.
3.) The bots at the end just stop moving for some reason (Need to fix).

I was also looking at this: https://trello.com/b/dmIooAod/blacklaceworking-board and most of these are gonna be deleted. The woes of working with non-concrete plans..

But in general I would say the main things left for this game mode are to integrate those lazy turrets I made a month or two back and ensure there’s a good death screen. Then from there the majority of the work will be aesthetic and polish (and a new gun or two).


Leave a Reply