Trouble Returning Ritual Items – Jonathan Kohl


Overall returning ritual items was a card that was deceptively challenging. I surpassed the expected time I thought I would need to work on this by several hours. What sounds somewhat mundane took a great deal of architectural design and I also ran into dependencies that I was not initially expecting. After collaborating with Whitman and Luna we were able to overcome these challenges and effectively implement this feature.

The first main issue was getting AI to recognize ritual items when the player drops them. Currently the AI perception will detect actors that enter their sight, so I tried casting the incoming actor to an ABasePickupItem to discern it from the player. After running the game and viewing the perception of the AI I noticed that it was not picking up the ritual item at all. I then began to suspect that there was an issue with the team ID of the ritual item, so I further examined the blueprint for the base pickup item.



I set the team ID to a number other than that of the enemy AI so that it would detect it as an enemy. After debugging, the AI was still unable to detect the ritual items. Then I looked at the components of the ritual item, this is when I noticed we were missing an AI perception stimuli source on the blueprint. Due to this being one of Luna’s additions, I immediately reached out to her so that we could collaborate in adding this component to the base ritual item. Finally, after testing we found that the AI could detect ritual items and would move towards it.



The next step was picking up the object by saving a reference of it on the blackboard, deleting it out of the scene, finding the original location of the object saved to the blackboard, and then navigating to the original spot to drop it off. Only unfortunately it would not work that simply. While debugging the behavior tree I could see the AI saved a reference to the object, deleted the object from the map, found a location to path towards, but then they would never begin pathing towards the original ritual item location. When debugging the code, we could see the task to drop items was never getting called.  “Move to” was getting executed on the behavior tree but it seemed to be immediately terminating with the AI starting to enter the wander branch of their behavior.


At this point I was in chat with the team working, discussing the issues I was having. Whitman then asked me if I was at any point deleting the asset from the map when picking it up. That’s when it hit me. I was Saving a reference to this object on the blackboard, deleting it from the map, then trying to find the location based on the object reference on my blackboard. I was accidentally deleting the reference to my ritual item, so an invalid location was being set resulting in the AI to change paths in the behavior tree. Consequently, I moved the cleanup of the ritual item to the task script of finding original location to after the location got set. After testing to see if this fix worked, the AI worked exactly as intended when returning a ritual item.


Leave a comment

Log in with itch.io to leave a comment.