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"

BUG? Spawned Actors don't replicate blueprints correctly

Hey, I recently encountered a bug with spawning replicated actors. So what I have is the blueprint below. A blank actor spawns a random trap from an array at begin play which is replicated to any clients, such that everyone sees that this trap is spawned. This works perfectly for when the actor is placed directly into the scene, but when spawned into the scene, the replication isn't synchronized. Any clue why this happens?

This is a screenshot of the blueprint inside my random trap actor. As you can see, it picks a class from an array variable inside the blueprint, in this example, a cylinder or a cone blueprint class. All three blueprints, the random trap class, the cylinder class, and the cone class all have the "Replicates" box ticked. alt text

Here's a photo of the traps being run in the editor. The bottom two are Random Traps placed directly into the scene, and as you can see, are replicated to the client correctly. The upper one is spawned into the scene through the Level blueprint's "Begin Play" node. In the upper one, the server only sees one trap, but the client sees both, which I assume is because it spawned a random trap while it also replicated the server's trap.

Server alt text

Client alt text

Product Version: UE 4.9
Tags:
trappic.png (169.0 kB)
server.png (703.9 kB)
client.png (686.8 kB)
more ▼

asked Nov 23 '15 at 10:20 PM in Bug Reports

avatar image

thecomediclife
21 4 8 12

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

1 answer: sort voted first

Hi thecomediclife,

Since the RandomTrap blueprint exists both on the Server and the Client, this is being run twice on the Server. First, the Server instance of the BP runs and spawns a random trap. Then the Client instance asks the Server to do the same, at the same position. That also explains why you see two different classes spawned: each time the Event is run, it's getting a random value for RandIndex.

You probably want to do this without the Run on Server replication, and only fire the event on the Server. You can specify this by using the Switch Has Authority node before calling the Event:

alt text

Hope that helps! Let me know if you have further questions.

more ▼

answered Nov 24 '15 at 09:02 PM

avatar image thecomediclife Nov 24 '15 at 11:12 PM

Hey Ben,

Thank for the quick response. Unfortunately, this didn't fix the problem. I changed it like you mentioned, and the blueprint runs fine when the random trap actor is placed into the scene, but when spawned into the scene using a "Spawn Actor from Class" node, the same problem above happens, where both the client, and the server spawn separate traps, sometimes the same one, sometimes different ones.

avatar image Ben Halliday STAFF Nov 25 '15 at 02:24 PM

Ah, I apologize, I missed that part of your post. Can you show me which BP is spawning the RandomTrap BP, and what the BP setup is for that? Thanks!

avatar image thecomediclife Nov 25 '15 at 10:28 PM

No problem. The BP that is running and being shown in the original post is in the project I sent you, in the folder Blueprints\Traps, named "RandomTrap." To reproduce the bug, you simply need to spawn the "RandomTrap" actor into the scene using the "Spawn Actor from Class" node, and using the PIE editor's 2 player feature. To see the difference between the two cases, you'll need to place one "RandomTrap" directly into the scene, and spawn the other, and you'll notice that the placed trap replicates correctly, but the spawned one runs it's BP twice.

avatar image Ben Halliday STAFF Nov 27 '15 at 04:19 PM

Right, but from where are you spawning it? Which BP? And are you limiting who spawns it to the Server?

avatar image thecomediclife Nov 27 '15 at 09:00 PM

Oh, yeah. The actors are being spawned in the level blueprint. The events go like this: "Event Begin Play" -> "Switch has Authority" (from the Authority node) -> "Spawn Actor From Class".

The "Remote" node from the "Switch has Authority" goes to nothing, so it's just the server spawning the actor.

avatar image Ben Halliday STAFF Dec 01 '15 at 11:28 PM

Hey again,

I tested this in a new map in your project, spawning the RandomTrap into the level from the Level BP, using Event Begin Play and Switch Has Authority. I didn't see the same thing happen. This is the setup in the Level BP:

alt text

This works consistently for me, combined with the following RandomTrap setup:

alt text

RandomTrap is set to Replicate, as are each of the traps. I'm not seeing any variation between Server and Client. Can you repro this in a smaller test project for me and send that my way?

randomtrapbp.png (172.8 kB)
avatar image thecomediclife Dec 02 '15 at 05:26 AM

Hey Ben,

Thank you so much for your time in helping me with this. Unforunately, I'm currently unable to send you the project until about this friday, but once I get the chance to, I'll try and see if there's any differences between your setup and mine. I'll let you know the results by friday-ish, and if it's still not fixed, I'll send you the project.

avatar image Ben Halliday STAFF Dec 02 '15 at 03:51 PM

Sounds good, no rush. I'll leave this post Resolved for now for tracking purposes, but reply when you have time and we'll pick it up from there. Thanks!

(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