I try to spawn and attach weapons on begin play. I have all possible replication settings in details set up (all components are set tu replicate, replicate movement is also on etc.)
In begin play I call custom event InitialSetup (it’s run on server and set to reliable)
In InitialSetup I spawn actor from class then attach it to component
collision when spawning is set to always spawn, mesh world tranform is set as spawn tranform
attach to component location and rotation is snap to target, scale is keep relative and weld is disabled
After that In my server everything is displayed correctly but client is not.
I can post it tomorrow morning (GMT time) - but I am not checking authority. Just calling event with replication set to run on server - isn’t it doing that automatically? (At least I haven’t seen this in blueprint replication wiki)
Well if you spawn a replicated actor with movement replication, that actor should be spawned on server only and engine does replication automatically…
Begin Play called on both Server and Clients, so if you spawn actor there that means you spawn 1 actor on server, 1-1 on clients.
Engine does not replicate anything from clients to server, only from server to client
technically if you spawn anything on client his position can be invalid since not updated from server (imagine like a standalone actor which exist only on that client)
I have updated question with BP code. I have added check but that still doesnt work (Still client has incorrect position). I have also added print and it is called only on server.
Ok, ive checked the code…
Well weird it seems fine. BP_Bow is also replicated and replicates movement right?
Okay, BP_Bow is replicated and replicates movement right?
Hand Mesh is the whole “pig”? or the sword? (Because seems to me sword is also on wrong location)
Hand Mesh replicated and replicates movement too?
So far code is configured properly. (btw you dont need server event if you spawn things on server, but its okay… event would be called anyway )
Both BP_Bow and BP_Sword replicates and replicate movement (just double checked). Hand Mesh is an invisible mesh (at lest invisible for now) thats ‘floating’ hand near pig (it’s attached to first person camera). I cannot see option to replicate movement on skeletal mesh.
idk, im out of ideas too…
code should be fine, but seems your hand mesh also not in correct place… and i assume its not runtime spawned mesh… should be some small things we missed maybe…
nah no project / world settings modify this i think…
simply hand mesh should be visible all the time (if you added as static mesh component) at correct location
these are BP_Sword replication settings (crossbow has the same). All other components has components replicates. After it’s spawned they move ok (so movement replication works) just location is wrong.
When added delay client sees his items correctly but character controlled by server has it in wrong place.
yeah beginplay can happen before replication happens…
but since you try to attach on server and replicate movement down should be not issue…
in theory you spawn the bow attach it on server side and you let engine replicates down his position…
i suggest one thing…
make a replicated Bow reference variable for now with repnotify and set as replicate for everyone… after spawn set the bow reference and wait for repnotify
if repnotify triggered (that means all client got the bow) try attach it to the handmesh on clients with snap…
im not home yet, but i would do a test project to test your problem
I have made it so I create actor on server then set repnotif and in it’s function I attach it. It still didnt work but I found this question above - and with small delay before set repnotify it works
EDIT: at least it works perfectly on button input … in begin play client still has issues with seeing server item (but his own item looks ok)
EDIT2: Expanding delay seems to fix it … but I still don’t understand the necessity of this delay.