Hi, I’m a beginner at UE C++, and I followed this tutorial to create a mesh actor via C++. Firstly, some of my code in myactor.cpp was like this:“static ConstructorHelpers::FObjectFinder CubeVisualAsset(TEXT(”/Game/StarterContent/Shapes/Shape_Cylinder.Shape_Cylinder"));
“After I clicked the “Recompile and reload C++…” button, a cylinder C++ class was created. Then I changed the code to:“static ConstructorHelpers::FObjectFinder CubeVisualAsset(TEXT(”/Game/StarterContent/Shapes/Shape_Cube.Shape_Cube”));
"and reclicked the recompile button, but the mesh C++ class didn’t become a cube at all. Only if I restart the UE editor, it will refresh. I also tried to delete the folders Binaries, Intermediate, and Saved, and the [PROJECT_NAME].sln file, but nothing worked. So, what can I do to fix this?
Hello,
It seems you’re encountering an issue where your C++ actor instances don’t update automatically in the level viewport after recompiling modified code. Let’s troubleshoot this:
Root Component Issue:
Ensure that the static mesh component you want to update is the root component of your actor. If it’s not, try making it the root component.
In your AMyActor constructor, set the static mesh component as the root component using SetRootComponent(CubeStaticMeshComponent);.
Location and Rotation Changes:
When you modify the offset transform (location and rotation) of the child component, make sure you’re applying the changes correctly.
Verify that you’re updating the correct component’s transform (e.g., CubeStaticMeshComponent->SetRelativeLocation(NewLocation);).
Recompile and Refresh:
After recompiling, try refreshing the level viewport by selecting the actor instances and using the “Replace selected actor with” option.
Unfortunately, automatic updates might not occur for C++ instances like they do for Blueprint instances. FloridaBlue