I am having an issue where the variables of my socket transform change based on whether or not the Host sees the Client. I have tried it with multiple clients and it is the same.
When I shoot, I do checks locally and then on the server I run a line trace that starts from a socket on my weapon mesh. If the host doesn’t see the client, the client’s trace is inconsistent. Sometimes it shoots straight down, sometimes it ignores the pitch, sometimes in hits the same spot. After the host looks at the player, the line trace functions correctly. The print string in the corner is the location and rotation of the socket when the weapon is firing. I don’t move much between tests and the numbers are drastically different
Does anyone know why this is happening and how to fix it?
Show you aim and shoot code. Something is definitely wrong here.
By default the game does not update animations for non-rendered meshes (optimization) - in your skeletal mesh component look for option “visibility based anim tick option” and set it to “always tick pose and refresh bones”
Also check your Tick Groups.
Animation happens in TG_PrePhysics
while Camera updates happen in TG_PostPhysics
.
The player’s animated actor would move and animate in TG_PrePhysics. It needs to animate before physics in order for physics-simulated objects to follow and interact with it correctly. Then Sockets, camera etc are ready to use in TG_PostPhysics
TG_PrePhysics
- This is the tick group to use if your actor is intended to interact with physics objects, including physics-based attachments. This way, the actor’s movement is complete and can be factored into physics simulation.
- Physics simulation data during this tick will be one frame old - i.e. the data that was rendered to the screen last frame.
TG_PostPhysics
- Results from this frame’s physics simulation are complete by the time this tick group runs.
- A good use of this group might be for weapon or movement traces, so that all physics objects are known to be in their final positions, as they will be when this frame is rendered. This is especially useful for things like laser sights in shooting games, where the laser beam must appear to come from the player’s gun at its final position, and even a single frame of lag will be very noticeable.
So the server renders it when it is in view which is how the location updates?
The choke here is you aren’t using Base Aim rotation
and Camera manager -> camera location
of the shooting pawn to generate a shoot at point down range. With that you can then shoot from muzzle toward downrange location…PostPhysics (tick group).