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"

[QUESTION] Apply Static Mesh to StaticMesh component

I'm sure it's accomplished by the SetStaticMesh(UStaticMesh *NewMesh); function. However, I'm not sure how to get the static mesh reference of the mesh from my content browser. Thanks.

Product Version: Not Selected
Tags:
more ▼

asked Mar 20 '14 at 07:18 PM in C++ Programming

avatar image

Skydive
116 18 24 24

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

1 answer: sort voted first

That's easy!

C++ Constructor

Right click on your static mesh asset and select "Copy Reference"

Than paste into code in constructor

 AJoySMA::AJoySMA(const class FPostConstructInitializeProperties& PCIP)
     : Super(PCIP)
 {
 //Mesh
 static ConstructorHelpers::FObjectFinder<UStaticMesh> StaticMeshOb_torus(TEXT("StaticMesh'/Engine/EditorShapes/Meshes/Shape_Torus.Shape_Torus'"));
 if (StaticMeshOb_torus.Object)
 StaticMeshComponent->SetStaticMesh(StaticMeshOb_torus.Object);


or

Blueprinted Class Property

.H

create a blueprinted version of your class, and make a UStaticMesh* so you can assign the static mesh in the editor.

The value set in BP should only be accessed after PostInit.

 /** SM Asset for Player Starts */
 UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category=StaticMeshAssets)
 UStaticMesh* AssetSM_PlayerStart;
more ▼

answered Mar 20 '14 at 07:21 PM

avatar image

Rama
10.6k 446 343 1085

avatar image Skydive Mar 20 '14 at 07:35 PM

Thanks!? It works! Where did you come across this? I need a great reference. Furthermore, how would I get the position of the static mesh component? I'm only struggling with the API. Steep learning curve, haha.

avatar image darkgaze Aug 21 '17 at 11:09 AM

You can read a longer description for the C++ version in Unreal Engine 4 Cookbook in Packt. You can read the first lines here. The books is from 2016 and I recommend it a lot.

https://www.packtpub.com/mapt/book/game_development/9781785885549/4/ch04lvl1sec55/loading-assets-into-components-using-fobjectfinder

avatar image M V X I Sep 13 '17 at 12:16 AM

Hey darkgaze, from where did you get this book? I tried to find a free pdf on google but I couldn't. Could you help me?

avatar image darkgaze Sep 13 '17 at 07:22 AM

Do what I did. Pay for it. It's worth it. I suggest you follow this website: everyday, they give a book for free. Other times books are 5 dollars or something like that. https://www.packtpub.com/packt/offers/free-learning

(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