Hi All,
Having a strange issue while developing a game im working on.
My project structure so far looks like this
GameManager
- Handles managing the seats of the game world, and spawning new NPC’s
- Only 1 per level, manually placed in the level
- Has a Map<GUID, Seat> called SeatIdToSeat
NPC
- Runs a BT, finds an available seat of the game it wants to play, and moves to it and plays the game
BaseCasinoActivity
- Abstract Class
- Defines basic behaviour for an Acivity, reused for multiple components like, Waiting Area, Roulette etc.
- Gets a list of seats from the child class when overridden
Seat
- A Place for an NPC to sit
- Has a state, Free and Occupied
- Occupier, the NPC that occupies this seat
Placed in the world is some Roulette tables, that inherit from BaseCasinoActivity.
BaseCasinoActivity uses the event, EventBeginPlay to grab the reference of the instance of GameManager using FindActorByClass, then the BaseCasinoActivity gives it a List of Seats it has by using the GetAllChildActors.
This will basically give GameManager all the seats possible in the world, and even if the user of the game adds more in later (later feature of the game).
When i debug into the function called ‘New Seats Added’ on GameManager the member variable SeatIdToSeats gets updated, and the count goes up with each subsequent call.
GameManager spawns NPC’s and gives it an reference of its self to the spawned NPC.
But later on when the NPC tries to call ‘Find Available Seat’ on GameManager the SeatIdToSeats is suddenly empty. And i’ve checked the GUID of GameManager in all uses and its the same. So any idea why it would be emptying?
Here’s some blueprints, im pretty new to unreal so sorry if they are a bit messy!
BaseCasinoActivity - EventBeginPlay
GameManager - FindAvailableSeat
GameManager - EventBeginPlay
GameManager - NewSeatsAdded