First off, apologies in advance for what I know must be a n00b question but it is exactly for that reason why I need your assistance, so again, please forgive my n00bness.
I come from a decade of using Unity and am finding the transition to Unreal incredibly hard. Quite literally anything I could do in Unity in under 30 seconds each take me hours or days to figure out in UE4… I am in desperate need of help (since all those 'Turn a box green"or “Pickup and drop this item here” courses are clearly not cutting it… )
So what I would have done in Unity is to create my base projectile prefab (the one I would move and which contains the collider), add my 4 projectile meshes as disabled child objects of the prefab then add them into a GameObject] array. Then, when I spawn the prefab, I would call an init(int) function that determines it’s speed, strength and mesh and with that being the case I could then simply do this:
What I have done so far in UE4 is I created the base BP, added the projectile meshes to it as static meshes, added arrays for movement speed and whatnot to be applied to the parent BP, configured the game’s input to spawn the BP and then passing an int value to the init function to determine all it’s properties. So far everything is working perfectly fine, the prefab spawns, it moves in the scene, all is well. Only one step remains: Show the correct mesh (right now I show all 4).
So I create a function called DisplayRelevantMesh, I created an array of type StaticMesh and then… then I find I can’t drag child objects of the BP into the array. As soon as I click on the mesh it deselects the array… When I try to select elements from the drop down it seems to want me to select something new to spawn instead of finding something that is already inside the BP…
So after about an hour of struggling with “How do I drag objects into an array” I finally gave up and said “Fine, every single time I spawn a projectile I will do finds and casting operations and just generally do a lot of overbloated code to simply enable one mesh and not the rest”… only to find that I can’t find any code to actually help me FIND the child objects of the mesh either… So I am now completely lost
I am thinking a quick shortcut would be to change this approach and rather just spawn a static mesh after I spawn the empty parent BP but this feels like a hack and I’m sure I will need this functionality again in future so I would rather find out the RIGHT way of doing this.
Can someone please share with me how to do the equivalent of that Unity code above inside a BP? I would be ever so grateful!
Thanks in advance