Server doesn't know where the gun is

Hi!

I have a gun, it attaches to the character and shoots (a server event) from the muzzle (a socket on the mesh).

When I move the character, the gun moves and shoots with it.

But when I crouch or aim, the animation plays on both server and client the gun moves with my character, but the muzzle position doesn’t update.

So when the character crouches, it looks like the bullets are exiting from his head.

Is there a way to tell the server where the gun is?

Yes, I’ve seen your problem before with the trace not following your sword swing animation. The code actually only stops working when I ask the server to get the socket position. The client can do it just fine so your theory makes a lot of sense.

I am going to try your solution when I get home. I’ll update with the results!

I was having similar problems when I used sockets to get a sword position. Does your code work on the server but not the client? If that’s the case we likely had the same problem.
Essentially the server doesn’t bother to update the client skeletons when it isn’t relevant, like animation culling, so to it the socket is still in the default idle position when the client actor isn’t being rendered. What I ended up doing was I had a vector variable that I updated every frame on the client (run on client, get socket pos.), and passed that data to the server (run on server, serverMuzzlePos = clientMuzzlePos). Then whenever I wanted the muzzle position I referenced this variable instead of having the server getSocketPosition.

This may or may not be your problem, hope it helps

Is this how you did it?

Oddly enough, in my case, it seems that for some reason, the blueprint is failing to set the variable. Very confusing!

http://i.imgur.com/J8x2UFg.png

At least that’s how I think I did it, I changed my melee system to be hitbox based instead of trace based.

This doesn’t seem to work for me. It looks like it should though. Perhaps there is some way to manually tell the gun where it should be when the crouch button is pressed? I’ll keep trying different things and reply when I’ve found a solution.

I’m also wondering if this is easier to do in C++

So, here’s something interesting.

When I hook up the event to Event Tick, I can see two versions. The correct version is the client’s perspective, the incorrect version is the server’s. Then upon doing a Print String for the XYZ coordinates, it seems that on the server, the gun isn’t following the animation like you suggested earlier. The server ONLY sees a static position that does not follow the animation.

In the Skeletal Mesh component details, set the “Mesh Component Update Flag” option to “Always Tick Pose and Refresh Bones”.

Jin_VE Not even joking, you have single handedly saved my game.
Thank you SO SO much.

I’ve literally had a problem with this for weeks.