GetComponentBounds returns 0 in constructor
I'm programming a unit in C++ from which every unit of my game will extend. This is only c++ and it has no BP component.
It has a Mesh and a Decal Component that can be adjusted via editor using UPROPERTIES, but right now I'm trying to attach it a default mesh and a default decal component material. The DecalComponent is actually a child of the MeshComponent.
So, in the constructor, I get the MeshComponent and attach to it a default mesh, referencing it via its path. Then, I get the Decal Component and attach to it a default material. The DecalComponent's rotation, position and scale depend on those of the MeshComponent, so I set RelativePositionAndOrientation and, talking about the scale, I try to get the SphereRadius of the Mesh using the GetComponentBounds function, but it simply returns 0 for everything. Code of this:
I think it has to be something about when the mesh is loaded, since I have bound an event that fires when the DecalMaterial is changed and then do the same, get the sphere radius and scale the material with it, and it works that way. But that's not the default behavior I want it to have.
Any ideas on how to get the sphere radius of a mesh in the constructor or how to know WHEN is loaded in order to be able to do it?
Thanks a lot in advance
OnConstruction may be a better place to try to do this, but what exactly are you calling GetMesh() on? Are you sure you're getting the mesh that you're looking for?
answered Feb 15 '16 at 02:53 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here