Hello,
How can i create/spawn a static mesh at runtime with C++ I tried googling but can’t seem to undestand it…
Here is a picture where it works with blueprint
Hello,
How can i create/spawn a static mesh at runtime with C++ I tried googling but can’t seem to undestand it…
Here is a picture where it works with blueprint
I also tried this in my for loop, but i crashes the editor
Make a pointer with a static mesh, and a pointer with static mesh component, in the constructor use the pointer to create the component then there is a series of attachment procedures to attach the mesh with it’s pointer to the static mesh component and attach the component to the root component, attach camera and arm spring component also this way.
Use a spawn mechanism with Tsubclass and the object component you are trying to spawn, expose the variable to blueprint . You can place this in the begin play function. You are mostly going to use the world function that has many presets availible for it.
It’s not one line of code, so best is to follow beginner tutorial on youtube on this since they are abundant and they represent the first steps towards working with C++ in Unreal.
So after this you have to learn to use the world function.
GetWorld()-> spawn whatever.
Following tutorial, but get error… while still doing the same thing the tutorial says
Edit: Fixed by changeing to Mesh->SetupAttachment(Parent)