Perception System in Blueprints

Before talking about the inventory system I need to explain how to actually get items. I believe there are thousand of possibilities, but I went with the most versatile one as I don’t know how many items there will be or what they will actually be able to do in the future.

But I needed a way to interact with the world surrounding the players, activate objects or take items. And for many reasons I decided to create most of the code and mechanics directly inside the character blueprint.

 

What bothered me in the first place was to check for an event every frame, but in my opinion this is way too expensive. So, as with the Day/Night system I actually decided to check every X seconds.

The main idea is to cast a sphere from the camera every 0.5 seconds and get the hit back, see if it actually touched an interesting item and then proceed with all the mechanics.

Here is the commented blueprint, click to enlarge:

Perception Blueprint
Perception Blueprint