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"

Attaching Components from Different actors.


So ive got an actor that has a mesh component attached to it. (Actor1) Ive got a second actor that also has a mesh component attached to it. (Actor2)

the second actor is spawned at runtime, and id like to attach it's mesh component to be a child of the first actors mesh.

Ive tried the following:

 Actor2->Mesh->AttachTo(Actor1->Mesh, NAME_None, EAttachLocation::SnapToTarget);
 Actor2->Mesh->AttachParent = Actor1->Mesh;

And indeed inside the editor i can see that the second actor appears as a child of the first: I.e:

      -> Actor2

However when i move Actor1's Mesh:


The second actors mesh simply doesnt follow it! Any hints?


Product Version: Not Selected
more ▼

asked Dec 12 '14 at 03:52 PM in C++ Programming

avatar image

55 8 8 15

avatar image Chronojam Dec 12 '14 at 04:32 PM

"ActorComponents are automatically registered when the owning Actor is spawned" - Both actors are spawned in the scene, so i dont think its a registration problem (Unless you mean doing some sort of cross-registration?)

As for the cross-attaching, the tl:dr version is that its the only way i could think of doing it,

(the above is a simplified example, but basically Actor1 has 2 meshes, and there are many Actor2's with 2 meshes each, which need to follow the appropriate mesh on Actor1)

avatar image Sachamora Dec 13 '14 at 11:31 AM

yes they are automatically registered, but to their initiator actor, I guess you have to register them again to the new actor.(just guessing)

avatar image Chronojam Dec 13 '14 at 10:57 PM

Aye, that's what I went with the in end, ( by making the meshs on Actor1 and Actor2 be thier own actor's with just a mesh component on it, and storing the reference via a pointer).

then that method worked perfectly, (sadly it didnt work initially as it would only attach to the root component of each actor, and i needed the cross attachment i mentioned in the other comment)

Seems a bit overengineered, but as long as it works ammiright?

Thanks for both your help, i guess it was just the wrong way of doing things!

(If you want to convert your comment to an answer ill mark it as correct) - Cheers!

avatar image Sachamora Dec 14 '14 at 09:57 AM

I converted it, thnx :D

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

2 answers: sort voted first

Have you tried

Actor2->AttachRootComponentToActor(Actor1, NULL, EAttachLocation::KeepRelativeOffset, false);

more ▼

answered Dec 13 '14 at 10:36 PM

avatar image

108 2 5 10

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

Do you register new mesh component to the Actor1? I think there is function inside AActor that does the registering, Look at registering component in here Beside, I really cant understand why you would like to attach a component of an actor to another component of an other actor, it seems a violation to philosophy of actor class.

more ▼

answered Dec 12 '14 at 04:13 PM

avatar image

152 14 16 22

(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