Hi folks - hoping someone might have some advice or tips on implementing forage-able resources on landscape foliage (e.g., mushrooms that can be picked from foliage-tool-spawned trees).
I have a functional approach, but I’m not convinced it’s optimal:
My first instinct is to do a trace on the instance you want to pick from to get its transform, then swap it out for a different type (i.e., swap ‘tree-with-mushroom’ for ‘tree-without-mushroom’). The clunky way I have this set up is to place (using foliage tools) one instance of each type of mesh in a known location (e.g., a non-player-accessible region somewhere in the level; I just dropped a plane underneath the landscape), then use a trace at that location when I need to spawn a new instance to swap out the old one. This works fine, but seems like kind of an ugly solution.
Another option would be to use a separate blueprint for the mesh add-ons (i.e., spawn the trees using foliage tools, then spawn mushroom mesh instances onto the trees at beginplay using a blueprint with something like a sphere trace and some randomization to choose which instances to add to). In this case, the tree mesh doesn’t need to be swapped, and we just need to remove the mushroom instance on collection. That saves a trace call in-game, but has a potentially large one-time cost at beginplay.
It seems very likely that neither of these solutions is particularly good, so I would be grateful for any advice or experience others might have implementing this kind of system!