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"

AttachToComponent and Replication


So I have a weird behaviour with Unreal's Multiplayer, more specifically with actor replication.

I started from the third person template and what I wanted to do was spawn a blueprint class from my character's BeginPlay method and attach it to the character, as the server is the only one that should spawn important objects I did it like this :

 void AMyProjectCharacter::BeginPlay()
     if(Role == ROLE_Authority)
 void AMyProjectCharacter::SpawnSphere()
     static ConstructorHelpers::FObjectFinder<UBlueprint> Bp(TEXT("/Game/Test"));
         MyBlueprint = (UClass*)Bp.Object->GeneratedClass;
         shape = GetWorld()->SpawnActor<AShape>(MyBlueprint);

Now the AShape class as these lines in his constructor :

 bReplicates = true;

Then as you see in the code above (the SpawnSphere Method) I call a function that is called AttachSphere and is like that :

 UFUNCTION(Reliable, NetMulticast, WithValidation)
 void AttachSphere();
 void AMyProjectCharacter::AttachSphere_Implementation()
     shape->AttachToComponent(RootComponent, FAttachmentTransformRules::SnapToTargetNotIncludingScale, FName("ShapeC++"));

Now this is what I get on the server :

alt text

Which is perfectly fine but on the client I have this :

alt text

The Spheres are absolutely not in the right place I've searched for long hours I found a post where people said that I should use AttachToComponent on the server and on the clients which I tried to do with the NetMulticast function but I can't get it working.

If any information is missing please tell me,

Thank you,

Product Version: UE 4.14
server.png (551.0 kB)
client.png (619.4 kB)
more ▼

asked Feb 24 '17 at 01:38 AM in C++ Programming

avatar image

31 3 4 7

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

1 answer: sort voted first

You don't need to run a multicast, as long as the Sphere is replicated you can simply in the server spawn and attach the sphere and that will be replicated automatically to all clients. Keep your code as it but make AttachSphere() a normal function that runs on server only, with sphere been replicated.

more ▼

answered Oct 08 '17 at 07:37 PM

avatar image

495 4 7 13

(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