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"

Attach to Component result in different Locations on Server and Client

Hi folks.

I get a weird behavior when I attach weapon actors for my multiplayer clients. I'm using the first person template and did some blueprinting to wait until enough players are connected. Then the server spawns the player characters and let them be possessed by the clients’ player controller. So far, so good.

Now on the "on possessed" node in the character blueprint I let the server spawn the weapon for that character and attach it to the projectile-sphere (a collision sphere attached to the character, like in the first person template). But after attaching them, they result in different locations on the server and on the client. On the server, the location is fine, but on the client, all weapons are attached with a strange offset.

I've tested with component replication but nothing seems to work properly. Any idea what I've done wrong? (The blue arrow in the pictures represent the position of the weapon actor.) alt text

Product Version: UE 4.14
server_client.jpg (196.5 kB)
more ▼

asked Nov 29 '16 at 05:19 AM in Blueprint Scripting

avatar image

178 6 12 11

avatar image Holybreath Nov 29 '16 at 01:57 PM

are you sure, its not the player character that is spawned incorrectly?

avatar image Lord7even Nov 29 '16 at 02:11 PM

Maybe. But what could be the problem when spawning the character? The server spawns them at a location of a player start with a scale of 1. Also the projectile sphere is visible at the correct place (Server and Client) and if I don't attach the weapon, it's at the correct place too. So I guess it's really something with the attaching thats wrong...

avatar image Holybreath Nov 30 '16 at 05:24 PM

Does your weapon have any collision presets that can interfere? that happens a lot. because if it has, this gives try to adjust location but always spawn stuff to happen. just throwing it out there.

avatar image Lord7even Dec 01 '16 at 05:14 AM

Ok, thanks for your hint. I'll check that out. But I guess thats not the problem. My weapon actors have just a scene component and some blueprint functions. no meshs or something that could collide (in my opinion). I'm gone try to set collision to "no collision" on both my weapons and the weapon mesh in my character BP.

avatar image Lord7even Dec 01 '16 at 05:41 AM

Tested with different settings now but nothing seems to work. Spawn rule is "Always spawn, ignore collisions". Also tested with "Don't spawn" but then it spawns it anyways, so I guess it's nothing with the collisions, thats wrong. I also noticed, if I just spawn the weapon actor, it spawns at the correct place (server and client) the "attach to" node makes things strange then. If I set the location rule to "keep world" instead of "snap to target", it keeps moving the arrow to a wrong location. This also happens if I set all the collisions to no collision.

avatar image Lord7even Dec 01 '16 at 07:35 AM

Well, if I put a delay of about 0.6 seconds between spawning the weapon actor and attach it to the component, it works. Probably it has something to do with the characters "use pawn control rotation" but I guess thats another topic.

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

2 answers: sort voted first

After working on this for hours and realizing it had something to do with some replication thing I don't understand, this was my fix. Note that all of the object's components are replicated(including itself), and these nodes are executed on server only. I guess the server only tells the client about it if there's a change for some reason, so I just added an instant change.

alt text

more ▼

answered Apr 25 '17 at 01:27 AM

avatar image

1 1 1

avatar image Lord7even Apr 26 '17 at 09:25 PM

After long time of ignoring the "issue" I fixed it as well. There was definitely something wrong with the replication. I guess I solved it with RepNotifys from the Weapon/Equipment reference variable. I don't need a delay anymore and everything seams to work fine. I'll post my solution (blueprint) as soon as I get a little time. Simply said: Server spawns weapon an sets weapon reference variable which is a repnotify. In the notify function I just attached the weapon like normal. Meybe I also didn't understand the whole replication stuff at first

avatar image rex706 May 15 '18 at 01:53 PM

Even though this post is old, I am having a very similar issue that I cannot find more information on. Mind sharing your solution?

avatar image Lord7even May 15 '18 at 10:43 PM

Like mentioned above: I have a reference to the weapon as a variable with repnotify (its ether not replicated, replicated or repnotify) if you choose repnotify, UE automatically creates a function called "VariablesName"_RepNotify or something like that. this function gets called on server and clients, if (usualy the server) changes it.the variable itself is also replicated. you will call the attache to component in the function and everything should work fine. Hope that helps

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

I still don’t understand why you had to go through all of this. Ue4 documentation states that any replicated actor that receives an attachment will automatically replicate the attachment. For example I have 2 replicated characters and a replicated actor if I interact with the replicated actor and set owner to the client and attach that component or actor to a slot on the replicated character the attachment should replicate. The location and transform data should be seen by other clients as soon as the replicated character becomes relevant

more ▼

answered Oct 20 '18 at 07:30 AM

avatar image

1 1 2

(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