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"

Weird behaviour, when trying to attach components to (yet unassigned) skeletal meshes in C++


While setting up a player character in C++ I was trying to attach some SceneComponents (in that particular case a CameraComponent) to a specific bone/socket of the characters skeletal mesh.

The problem was, that I didn't want to further specify my skeletal mesh in C++ but rather create a blueprint out of my C++ class and assign the mesh there (in order to keep my C++ code clear of any assets).

So I was basically trying to use a socket in my C++ constructer, that didn't exist at that point of time. It simply didn't work.

 /** Non-functional cpp-code */
 FName MySocket = FName(TEXT("SocketName"));
 // This socket won't exist until the BP derived from this class is set up in the editor
 MyCamera = CreateDefaultSubobject<UCameraComponent>(TEXT("MyCamera"));
 MyCamera->AttachTo(GetMesh(), MySocket); 
 // NOTE: Will replace AttachTo() soon by AttachToComponent()

Things started to get weird when another user suggested to create a second camera (with identical properties) and attach it to my mesh as well.

  /** This DID work however! */
  FName MySocket = FName(TEXT("SocketName"));
  MyCamera = CreateDefaultSubobject<UCameraComponent>(TEXT("MyCamera"));
  MyCamera->AttachTo(GetMesh(), MySocket); 
  Camera2 = CreateDefaultSubobject<UCameraComponent>(TEXT("Camera2"));
  Camera2->AttachTo(GetMesh(), MySocket); 

It worked, both cameras behaved like originally intended and sticked to the assigned socket. I would just like to understand why so I can work around this problem in the future (allways creating spare-components isn't a solution). The user who suggested this workaround blamed this behaviour on an engine bug.

Could that be the case? Or did I cause this error?

If you need more details, feel free to take a look at the original quetion:


Thanks in advance!

Product Version: UE 4.18
more ▼

asked Dec 13 '17 at 09:04 PM in Bug Reports

avatar image

10 3 6 9

(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