Static mesh subcomponent in code, spawns at world center when placed.
I wanted to create a pickup item for my game similar to the "PizzaPickup" described in the programming introduction video, but having the UStaticMeshComponent already defined in my C++ class. So in the header file I defined the following property:
And in the implementation constructor I did:
I did it this way because I wanted to have a blueprint with the mesh component already available, but with no mesh set. Also, i wanted to set a default offset of the mesh, slightly off the ground. Either way, with or without the offset, I launch the editor and create a blueprint based on my class. Setting a mesh in the component, and everything looks fine in the blueprint editor.
But once I place an instance of the blueprint in my scene, the bounding sphere gets placed correctly, but the mesh itself seems to spawn in the world center. No matter how many instances I place, the root (sphere) always ends up in the correct location, but the meshes are all bundled up in the same spot.
For now I've added the static mesh component via blueprint, and then it works fine. But I'd really like to have this in the code, so I can set some default behaviour for pickups, such as the mesh offset off the ground, and some pitch.
Any ideas? Am I doing something wrong?
asked Mar 26 '14 at 02:12 PM in C++ Programming
Even though the components are created inside an actor object, you still need to attach them to have them inherit transforms. Try adding this:
answered Mar 29 '14 at 07:03 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here