How to package code + components for reusability inside blueprints?

Hello,

I’m trying to find a way to package code with also components for reusability inside a blueprint. I was looking at doing something like an Actor Component that I can add to blueprints that I want to have the functionality on, but for the life of me I can’t find a way to do it including other components.

I guess it’s better with an example:

I have multiple different type of shelves that are created with blueprints. I want to be able to add to this blueprint a “Slot” component - a component that has a collision box (to detect if an item was dragged into the slot) and inside the component, hold the code to snap the item into place in the slot, track qty, etc. I want to be able to reuse this “Slot” component for other shelves, counters, etc. I know I could do something like add collision boxes myself inside the parent blueprint and loop through inside the component and handle each individually and bla bla bla but I’m just looking for a way to have reusability with component grouping. Any ideas??

And I’m trying to avoid Child Actor components that hold other blueprints - I read that this is not ideal performance wise and strongly not recommended.

Thanks!

I don’t think using child actors would harm your performance and actors with seemly pretty simple logic as the ‘component’ you are describing. you can even turn off ticks for that child actor class, but at least you are planning to have thousands of shelves running in the game with a lot of items crunching a lot of math I doubt using a child actor causes important performance issues.

What you describe is exactly a child actor.

1 Like

Yeah that’s what I was thinking but it’s from this post (https://www.reddit.com/r/unrealengine/comments/9xry97/clarity_on_when_to_use_actor_component_vs_child/, granted it was a post from 4 years ago…)

Just checking if there’s anything else that could be better!