Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

C++ editor spawn static mesh

This is more a problem of me not knowing what to search for, and looking for the way. In C++, when I create a component and add it to an actor, at runtime everything works as expected. The problem that I am unsure of is related to the editor.

If I open an actor blueprint and add a static mesh component to it, when I change the static mesh it appears in the viewport of the blueprint. Also when that actor is placed in the level, the static mesh is visible in the level.

If I create an actor and add a static mesh component to it through code, it is created correctly and at runtime it spawns the mesh correctly. However, I do not see the mesh in the viewport, and when I place an actor in the level, the manipulator widget appears correctly, but there is no mesh. To be explicit,

  • Create actor in C++

  • Add static mesh component in C++

  • Derive blueprint from actor

  • In editor, set the static mesh component

  • Static mesh does not show up in viewport

  • Drag blueprint into scene

  • Static mesh does not show up in the scene

My guess is there is another step, but I'm not sure what to search for to find that step. I only find pages related to creating and attaching components. Can someone point me in the right direction?


Product Version: UE 4.14
more ▼

asked Apr 27 '17 at 12:12 AM in C++ Programming

avatar image

21 1 2 2

avatar image MC1RScorpion May 20 '17 at 05:12 PM

I am experiencing the exact same behaviour and would appreciate any insight into the reason or the solution.

avatar image Nachtmahr May 20 '17 at 11:54 PM

Would be nice if any off you can provide source Code. We are not Mindreaders after all =)

(Upload to www.pastebin.com or similar sites)

avatar image terryl May 22 '17 at 08:46 PM


I never found out the solution to this, so we have worked around it instead. If I need something to show up in the viewport, I have been adding those components directly in the editor. For components that were added in C++, we can select and move the transform in the editor, but you will not see the associated object.

avatar image terryl May 23 '17 at 08:16 PM

So, I just tried this again with the following code. This works as expected. We are using a custom build of 4.14, but we have not made any changes to "fix" this issue. It appears to have fixed itself, so it may just require a restart of the editor and/or PC.

 // VRPlayer.h
 class SHARED_PROJECT_API AVrPlayerTestPlayer : public APawn
   AVrPlayerTestPlayer(const FObjectInitializer& ObjectInitializer);
   UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "BRB|Actor|VrPlayer")
     UCapsuleComponent*  SceneRootNode = nullptr;
   UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "BRB|Actor|VrPlayer")
     UStaticMeshComponent* VRDebugStaticMeshPlayer = nullptr;
 // VRPlayer.cpp
 AVrPlayerTestPlayer::AVrPlayerTestPlayer(const FObjectInitializer& ObjectInitializer) {
   SceneRootNode = CreateDefaultSubobject<UCapsuleComponent>(TEXT("CapsuleComponent"));
   VRDebugStaticMeshPlayer = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("StaticMeshComponent"));
   VRDebugStaticMeshPlayer->AttachToComponent(SceneRootNode, FAttachmentTransformRules::KeepRelativeTransform);
 AVrPlayerTestPlayer::~AVrPlayerTestPlayer() {


Create a blueprint from this actor. Open the actor in the editor. Set a value to the static mesh component. The viewport, which previously did not display the static mesh, is now correctly displaying the static mesh.


static_mesh.jpg (74.9 kB)
avatar image GigasightMedia May 23 '17 at 06:31 AM

Are you adding the component in the C++ constructor, or within another method?

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

0 answers: sort voted first
Be the first one to answer this question
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question