Hello! I’m currently trying to script a system whereby a NPC is generated with a set holiday length. This NPC the has its holiday length decremented every day until it hits zero. For now the actor gets removed from the guest list array and is destroyed. Later this will be expanded to the npc leaving and heading home.
The problem is is that this isnt working as intended. I keep getting errors when trying to remove the NPC from the guest list array and and destroy the actor.
Thanks for any help you can provide!
See the code below —>
I took a quick look at this, two glaring problems are:
- This wont work unless you use a reverse for each:
- Why is the main loop on tick? Tick runs every frame, it would be much better to use a timer.
I’ll look a bit further.
EDIT: And this is failing ( errors about writing ints ), because of the problem above:
Yep, completely agree. Fixed it earlier today by resolving the two issues you’ve highlighted. Thanks for your response. These scripts attached seem to be working for me at the moment.
Reverse for each loop also has the same issue!
Glad to hear it.
I’d just add that if you have a lot of NPCs, it might well run like a dog with a wooden leg, unless you change that tick to a timer
Hey guys! I Improved the efficiency of this BP by using interfaces between the level BP and the guest manager BP, removing the need for the OnTick. This now only fires the update functions if the days has changed.