Creating meshes in the constructor vs blueprints

Hi, I’m transitioning from Unity and I was wondering about the difference in workflow here.

Is it standard to construct the static meshes through code like the method in this video?
My first thought would have been to add the meshes to a blueprint in the editor, and then somehow access them or assign them to the script?

The advantage of the method here seems to be that you already have access to the components, and you can be sure that they will exist.
But does this restrict how much you can change the blueprint in the editor? We are setting up all of the meshes and their attachments here, so if I want to change anything it seems like I have to do it through code.

So mostly I’m just wondering if there is an alternate way of doing this, or if this is best practice and I should get used to setting everything up in the constructor?

Thanks

Setting the meshes was done in the editor. Only attachment was done in code.


It’s by far the easiest if you ever want to refer to them in code. I can’t think of any restriction other than attachment and that’s going to rather rare to change and if it is, it’s not a tricky thing to do.

They were also added as components through the code though, so I was thinking about if you wanted to add more meshes etc; but I guess it’s only necessary because we need to access them in C++, otherwise you could just add the mesh components in the editor?

I think you’re conflating static mesh components with static meshes? Only the components were created in code and then their static meshes were assigned in blueprint.

No I understand the difference, but I mean say I wanted to add a third static mesh component, or even attach a light or something, would I also need to add that through code or could I just drag it in through the editor?

And generally speaking, if I set up a blueprint with static meshes or other components through the editor, and then wanted to add C++ functionality to it later on, how would I go about doing that?
Because the components I want to use already exist, could I assign them somehow in C++, or would I just need to start over and construct new components?
Maybe if I give the existing components the exact same name as the ones in the constructor in C++? That’s something I need to try out

Okay so I think “GetDefaultSubobjectByName” is kind of what I was looking for in this last reply, but I can understand that it’s still definitely not best practice to do this. I think I will just need to get used to setting up the C++ class before the blueprint now

This is essentially what my reply would be. There’s also FindComponentByClass if you know there’s just the one of that type.

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.