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"

[Closed] How to replicate components spawned at runtime?

Hi, I'm trying to add components to an actor at runtime and then have them replicate.

The actor's constructor:

      // Set this actor to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
     PrimaryActorTick.bCanEverTick = true;

And a function that is called on the server:

 void ABuildingBlockGrid::SpawnBlock()
     UBuildingBlockComponent* block = NewObject<UBuildingBlockComponent>(this, UBuildingBlockComponent::StaticClass());
     block->AttachToComponent(RootComponent, FAttachmentTransformRules::KeepRelativeTransform);
     block->SetIsReplicated(true);    // <- Causes disconnection

This works fine in singleplayer, but it causes my clients to disconnect when "block->SetIsReplicated(true);" is called. If I don't call it, my clients will be able to collide with it at the actor's location, but not see it. What would be the proper way to do this?

EDIT: I found the solution on the forum. Closing thread.

Product Version: UE 4.13
more ▼

asked Dec 02 '16 at 10:47 AM in C++ Programming

avatar image

111 2 4 9

avatar image AdamBors Dec 06 '16 at 06:01 PM


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

The question has been closed Dec 28 '16 at 11:54 AM by AdamBors for the following reason:

Found solution elsewhere, updated OP.

1 answer: sort voted first

I am not an expert on Component replication, but if it works just like Actors, then you have to just spawn the component on the server, it will replicate automatically to all clients.

more ▼

answered Dec 06 '16 at 06:25 PM

avatar image

1.1k 31 12 47

avatar image AdamBors Dec 06 '16 at 06:52 PM

My main issue is that clients disconnect when the component calls SetIsReplicated(true); on the server.

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

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question