# NPC behavior and FindCreativeObjectsWithTag best practice

**URL:** <https://forums.unrealengine.com/t/npc-behavior-and-findcreativeobjectswithtag-best-practice/2107457>\
**Category:** Programming & Scripting\
**Tags:** unreal-editor-for-fortnite, fortnite-creative, fortnite\
**Created:** [November 6, 2024, 7:54am UTC](https://forums.unrealengine.com/t/npc-behavior-and-findcreativeobjectswithtag-best-practice/2107457 "2024-11-06T07:54:39Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

**Author:** ![zoakibo](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@zoakibo](https://forums.unrealengine.com/u/zoakibo)\
**Post date:** [November 7, 2024, 9:19pm UTC](https://forums.unrealengine.com/t/npc-behavior-and-findcreativeobjectswithtag-best-practice/2107457/7 "2024-11-07T21:19:29Z")

</div>

Great stuff. Managed to resolve the issue based on your direction. Thanks!

For anyone else facing similar issues, I did the following (I imagine there might be cleaner ways to pull this off):

1. Setup a weak map in the creative device required to be called from the npc\_behavior.  
`var GameManagerMap : weak_map(session, game_manager) = map{}`
2. Populate the weak\_map in the OnBegin method of that creative\_device:  
`var currentSession : session = GetSession()`  
`if (set GameManagerMap[currentSession] = Self) {}`
3. Retrieve the creative device in the npc\_behavior:  
`var currentSession : session = GetSession()`  
`var GameManager: ?game_manager = false`  
`if (GameManagerProxy := GameManagerMap[currentSession]) { set GameManager = option{GameManagerProxy} }`

---

_[View the full topic](https://forums.unrealengine.com/t/npc-behavior-and-findcreativeobjectswithtag-best-practice/2107457)._
