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"

UStaticMeshComponent invisible in game

Hello, I am trying to redo an entire BP into C++ to create a more versatile Master class. However I have run into a problem. I have been able to redo everything but the components of the BP and at the moment I am struggling with getting the static mesh to work at all. I have created a simple static mesh component like this: (It's being inherited but I have editable when inherited enabled) if that matters.

 UPROPERTY(BlueprintReadWrite, EditAnywhere)
         UStaticMeshComponent* StaticMesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("Static Mesh"));

Then I have replaced every time the editor made static mesh was used with my c++ made one but the static mesh wont even show up in the game. Am I missing something fundamentally or is the problem something non code related?

Product Version: UE 4.19
more ▼

asked Dec 27 '18 at 04:34 PM in C++ Programming

avatar image

23 3 3 8

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

1 answer: sort voted first

Hey, initialisation should be done in the constructor.

so keep this : UPROPERTY(BlueprintReadWrite, EditAnywhere) UStaticMeshComponent* StaticMesh;

and add this :

 StaticMesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("Static Mesh"));

and with a rebuild you should be good :)

more ▼

answered Dec 27 '18 at 04:47 PM

avatar image

1.6k 15 18 34

avatar image FittFräsen Dec 28 '18 at 04:03 PM

It's still not working, and with a close look I can see that my "Set Static Mesh" node returns false despite the "New Mesh" input having a valid static mesh as it's value. And the Static Mesh Component does have mobility movable so it isn't that.

avatar image FittFräsen Dec 31 '18 at 03:38 PM

There was apparently a transform problem causing me to not see the static mesh. Thanks for the quick answer but why aren't static meshes bound to their root the same way as if they were made in BP's? I have attached it to a Scene Component and keept it's transform rule relative

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
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