Attach to Component result in different Locations on Server and Client
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.)
asked Nov 29 '16 at 05:19 AM in Blueprint Scripting
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.
answered Apr 25 '17 at 01:27 AM
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
Follow this question
Once you sign in you will be able to subscribe for any updates here