How do I cast to any child of a parent class?

I’m making a harvestable parent class (BP_Harvestable) that has a few children (so far just BP_Tree_1) and I need to do a raycast from the player and cast to any of BP_Harvestable’s children, however I can’t just cast to BP_Harvestable since it isn’t a BP_Harvestable but a BP_Tree_1 and I can’t do the class since it isn’t the class. I have attached a screenshot of the code.


Keep in mind I am sort of new to Unreal Engine and Blueprint so there is probably an obvious solution that I just don’t know about.

1 Like

Casting to the parent should work for all the children, just to know if it’s harvest-able.

The problem comes when you want to drag from the cast, and call stuff inside the BP.

Two ways around this problem are

  1. Put all the common code inside the parent, and only implement the specific stuff in the children. You can have a custom event like ‘harvest’ in the parent, but the instance code is different in each child. You do this with something called ‘overrides’.

  2. Use an interface to talk to the BP. Then you don’t get any of these problems.