x

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"

Preview Meshes for C++ Actors

Hello!

I'm struggling abit with setting a preview-mesh using C++. I've created an actor class and a UStaticMeshComponent called "CurrentMesh" within it which I want to assign a static mesh to. I have also made a TArray of static meshes (which is blank until it's edited in blueprints) which the UStaticMeshComponent can choose meshes from. If the index 0 of this array has been assigned I want to apply the mesh of it to my UStaticMeshComponent, although I don't know how to accomplish this.

My main idea was to assign it in PostInitProperties, but whenever I compiled it would just return a breakpoint in Array.h. Here's the breakpoint:

alt text

Now, I see that checkf checks if the index is greater than the array length, so I put it into an if-statement which checks if the array-index is valid:

 void ADefaultPlantActor::PostInitProperties()
 {
     Super::PostInitProperties();
 
     if (MeshStages[0])
     {
         CurrentMesh->SetStaticMesh(MeshStages[0]);
     }
 }

Although this didn't fix anything, and just returned to the same breakpoint. And if this helps: I'm using uint8 for my array.

Does anyone know how I would accomplish this? I simply want to display a mesh/preview mesh for the actor whenever I'm in the editor. Think of it as the blueprint-construct; you drag out from the construct node and set a static mesh like this:

alt text

Thanks in advance! :)

~Stefan

Product Version: UE 4.19
Tags:
more ▼

asked Jun 24 '18 at 06:20 PM in C++ Programming

avatar image

Steferich
109 4 7 9

(comments are locked)
10|2000 characters needed characters left

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