Projectile Replication rotation issue.

I have server fire working. Line traces and green debug points show up for everyone. My up/down aim offsets replicate and are seen by all players. When I spawn a projectile locally, it fires in the right direction. Once I move those nodes to run from the On Server node, the up/down direction is lost (as showin in pic, green debug is where aiming, bullet holes are where the projectile impacted). I have tried workd transform, get camera eye direction, camera rotation, etc to no avail. The local is using Muzzle socket location and rotation ( as I have seen in a few videos) and works great. What am I missing when replicating the bullet spawn?

This is the transform create that plugs into the projectile spawn.

and this is the local firing that works great


I don’t know how to solve this using blueprints but unreal shooter game has a C++ function exposed for this using remote view function.

you can try this solution instead:

All it does is, make a replicated variable to store your pitch value taken from control rotation (Control rotation needs Player controller so this would only work on the owning client and server), once you got the rotation you just skip the owner as you don’t need to overwrite the rotation again from server to owning client.

This is a good solution, my only addition to this would be just make it a float instead of rotator.

1 Like

Thank you, I will take a look. I am not a C++ dev, but will see what I can get from it.

So it turns out I already have nearly this exact blueprint for ControlRotationRep as it is used to replicate the aim up and down visuals and it works for that.
I applied it to my projectile rotation spawn and its better, but not completely accurate, The more you aim up or down the further the projectile moves from its spawn point and I can only think that the socket spawn point is staying at straight out from waist as well. ??

Edit: drew some debug spheres and I get 2 for the muzzle socket, one at end of barrel and one that stays at “waist” level and that is where the projectiles are coming from.

How do I remedy this?

Okay since you are running the logic on server, what you can try is just send the server the location and rotation via client and then spawn projectile/trace not need to do the whole thing like getting socket location and rotation on the server.

I will try to reproduce this when I get home and see what happens.

Check your skeletal mesh properties under “Optimization” there’s a property “Visibility based anim tick option”.
If it is NOT set to “Always tick pose and refresh bones” then it’s not gonna update on dedicated server and your sockets transforms will always remain at default position (waist) and rotation.

Trace from camera gives you a trajectory that will align with crosshairs.

For server side you can use Get Control Rotation → Forward Vector

  • For initial speed setups you’ll use the transform and muzzle velocity.
  • For Velocity setups you’ll use the Auth location and the (normalized vector * muzzle velocity) value.

So in normal circumstances you will run 2 traces one on client side(mostly for effects and other cosmetic things which won’t need any server validation i.e. hit effects and bullet tracers) and the 2nd trace is where you would deal damage this is what I believe you want to run completely on server side if I understood your question correctly.

Here is how it looks, I am only doing traces on server side for both server and client(s).

This is all it takes:

Note: If you don’t want to use control rotation you can send the Vector as an Input to the “ServerWeaponTrace” function.

To replicate the pitch simply follow the tutorial I linked above, its only for cosmetic purposes so you can see other players pointing their guns in correct direction.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.