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.
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
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’.
Use an interface to talk to the BP. Then you don’t get any of these problems.