Thanks! The missing part was in front of my nose all the time. In the client tracer function, I had the max target distance float from barrel to camera center disconnected and pushed to the side. After I connected it back, it worked like a charm. But your way looked simpler so I took that instead
I also took @Rev0verDrive advice on getting the pawns base aim rotation for the end tracer so I combined his suggestion with your implementation (starting the camera trace where the Target Arm Length ends (if I understand correctly, that is so the client tracer does not register a hit behind the character), so now my client tracer function looks like this:
@Rev0verDrive About the projectiles explanation, I don’t have actual projectiles yet, but when I incorporate them, I will definitely keep your advice in mind!
Maybe another question regarding one of your replies from earlier. You mentioned that I should do the full auto fire on the server side, but what I’m not quite understanding yet is how could I tell the server when I move my aim somewhere else while still keeping only one RPC to the server?
For example:
Client tells the server “I started shooting full auto” and sends the aim location => server begins firing the full auto at that location => client moves their crosshair somewhere else (tracer lines change) => what happens next? Do I need to make another RPC to tell the server my aim changed?
Well I’m guessing you could already probably get the aim direction from replicated data.
If the character replicates it rotation and pitch then you already have most of the needed info.
You could try moving the firing calculations to full server side (probably safer to not allow cheating), then you would just send the start fire / stop fire RPC
I’m still wondering if we can in some way avoid replicating the information about the center of the screen from the client. That seems like the only hurdle,because the server camera from the camera manager isn’t the client camera, I’m not even sure the client proxy on the server even has a camera manager per say (probably not).
Alright, I just tested with providing the player controller reference to the server event and it works But If you have a better approach, all the better
If I understand correctly, since you didn’t do the “HasAuthority” check (should there be an authority check?), it means this server function can be executed by all the clients, and therefore these references for camera and mesh that you get are also client’s references instead of servers?
Sure you can add an authority check for sanity sake But the function executes on server (as seen in the event definition).
Edit: Also all debug messages show it’s server only logic
But how are you then getting the clients Camera and other references, if it is executing on the server? Would that not get the server players references?
I’m not referencing the camera manager but specific components inside of the character model.
It seems they are replicated probably to denote where the character is looking (might be getting info from controller rotation deeper in the hierarchy, I would have to analyze the default character internals to be sure).
Oh and if you want to shoot a physical projectile then you can spawn it at the socket position & get the rotation from x of the vector the subtraction of the source (socket) and target vector (linetrace hit).
I had some trouble replicating your approach, because if I use the Follow Camera for calculating tracers, I get the original issue that I had when creating this topic (on client, the tracers shoot slightly down and left from the crosshair). So what I did was pass the Camera Manager → Camera Location to the Server event.
But what I’m having trouble with now is that the IsFiring boolean does not seem to be replicating when trying to fire on the client… (on server, it works fine ofc). Should the Replication Condition of the variable also be set to something?
Edit: Correction, I had to pass in the players Camera Manager instead of the Camera Location directly. If I passed the camera location, the line tracers would get inconsistent when moving the mouse around while shooting.
I think I found the problem with the shooting on client being a bit down and to the left. As @Rev0verDrive said earlier, if you get the Follow Camera reference, it will have the default position reference. Which is okay if you don’t have any camera position changes I guess (crouching, switching shoulder, etc). But in my case, I had a Zoom function on right mouse button click, which would change the camera boom offset to some default values, which I later changed.
So now I can actually do it like you, and use the Follow Camera. But I’m still thinking about refraining from doing that, because as @Rev0verDrive mentioned, if I implement crouching for example, the server will still use the default standing Follow Camera position…
Does the isFiring set to true near the input get triggered to true correctly?
Yes, client sets the value to true, I did some console outputs and this is the result: