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"

How to set a SkeletalMeshComponent through C++

I created a custom class which inherits from the "Pawn" class. I gave it an object of SkeletalMeshComponent. In my content browser I have a character skeletalMesh.

In runtime how can I set my classes skeletalMeshComponent to a copy of that skeletalMesh?

Product Version: UE 4.10
Tags:
more ▼

asked Dec 02 '15 at 05:09 PM in C++ Programming

avatar image

gamebro2222
6 2 3 6

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

1 answer: sort voted first

Hey gamebro2222-

You can use a constructor helper function to get a reference to your skeletal mesh and then use the reference to set the skeletal mesh component. https://docs.unrealengine.com/latest/INT/Programming/UnrealArchitecture/Reference/Classes/index.html#assetreferences This wiki page has information that should help with setting up and using constructor helpers.

Cheers

Doug Wilson

more ▼

answered Dec 02 '15 at 06:25 PM

avatar image gamebro2222 Dec 03 '15 at 09:37 PM

those "Asset Referencing" scenarios are very clear and helpful. But how about the function "LoadObject<>" isn't that a proper way of referencing an asset?

like if I was not creating an object with a hard coded model. I would not hard code it in the constructor.

Wouldn't I else where when I create this new class object fill out its skeletalMesh data there?

Example: Player has selected that the ball they want this match to be the spikey ball. You wouldn't create a new class for the spikey ball if it worked identically to all the other balls besides the fact its a different mesh. So in this case wouldn't you just create your "Ball" object then update its skeletalMeshComponent skeletalMesh reference by setting it to the return object of "LoadObject<"SkeletalMesh">( "Asset/Ball_SkeletalMesh");

Or am I thinking about it incorrect or an improper approach.

avatar image Doug E ♦♦ STAFF Dec 03 '15 at 10:14 PM

The constructor helpers are mainly used for setting up the defaults of a class or derived blueprint. If you're trying to set a skeletal mesh at runtime, using FindObject or LoadObject may be a better choice depending on if the asset is already loaded or not. For more information, this documentation page talks about using LoadObject() and FindObject(): https://docs.unrealengine.com/latest/INT/Programming/Assets/ReferencingAssets/index.html

avatar image gamebro2222 Dec 21 '15 at 08:12 PM

would this also work for making an instance of a skeletal mesh? or would FindObject, LoadObject always return the same reference?

avatar image Doug E ♦♦ STAFF Dec 22 '15 at 02:42 PM

In the call to LoadObject you specify the path where the asset to load is in the project. You can make multiple calls, each time indicating a different blueprint or other asset in the project to be loaded.

(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