Hello everyone,
I have a problem that I don’t understand at all and I hope you can help me.
I am currently trying to line trace by channel in the third person game.
I first did a trace which goes from my camera to the crosshairs. This also works wonderfully. Then I wanted to trace from my other camera (first person) to the same point to check if the path between the player and the targeted position is clear. Strangely, I now get two lines with one trace.
Can anyone tell me how this happens or how to fix it?
Many thanks in advance.
Okay, I found out where the second line comes from. The trace process is probably executed simultaneously on server and client. The client is the one that is displayed correctly, the server is offset. So now I just have to find out why the server is not executing the trace from the same position. TP and FP camera are in the same character so why does the TP camera use the same position on the server as on the client but the FP camera does not?
You are doing the trace on tick. The client and server have slight differences (client always needs to catch up to the server) You will never get them to synchronize if you are changing the camera angle.
Do a debug draw sphere of the camera position with different colors for the client and server (use the has authority node to branch) and you will see the difference between them.
This is also just an example structure because I have noticed again and again that I had problems with the trace. Normally I don’t do this with the tick, I only used it now to get a continuous update of the line to see what’s wrong.
I was aware that the traces are not the same during a movement, but at the latest when I just stand still like in the picture and there is no movement, the position on the server and on the client should actually be the same. or am I wrong?
it depends if “tp kamera” and “fp kamera” are replicated. Normally the camera spring arm derives it’s data from the character controller, if you are using a different setup then perhaps the two components aren’t in sync.
The debug draw sphere was a good tip. I noticed that when I move my camera keeps the rotation (as I wanted it to) at least on the client, but on the server it seems to rotate with the movement of the character, so the camera moves to a different position. My fp camera is not attached to a spring arm, but directly in the capsule compnent. I think I have a basic camera problem somewhere, I just imagined taking a TP character and giving him a FP camera and just switching back and forth by setting one to new active and the other to not. Everything worked fine until I got the problem with the traces.
Let’s see if I can find instructions somewhere on how to turn a TP character into a TP and FP character so that it runs in the client and server syncron.
in tp mode i have deactivated “use controller rotation yaw” and activate it in FP mode. since the problem with the shifted fp camera only occurs in tp mode i think this setting is to blame. otherwise i don’t know what’s causing it at the moment. but why is it not applied even if i run it on the server. or it’s something else xD
It is really due to the deactivation of the “Use Controller Rotation Yaw” setting. On the positive side, if I switch it back on permanently and not just in FP mode, then the tracing works. On the negative side, however, I can no longer circle around the character with the camera in TP mode without it rotating the character with the camera xD so I can only see the back
Have both the fp and tp camera be on spring arms. Just make the arm length short on the fp camera.
Also what is you fp camera setup like? Are you attaching it to the head bone?
You could also just do a trace from the center of the screen => into the screen depth and ignore any camera directly to have a consistent trace.
my TP camera has a socket offset so i can’t just trace from the middle to the front. but i could add the offset if necessary to get to the necessary starting point. but the point (camera, or socket on the skeleton) would normally be easier if it didn’t cause so many problems now xD.
so either I find out how to keep the FP camera syncron with deactivated “Use Controller Rotation Yaw” or I have to live with the fact that I can only see the back of the character or I have to make some detour that recalculates the starting point of the traces.
Thank you for your help, otherwise I probably wouldn’t have found the actual problem so easily. but now I have to go to sleep because I have to get up in 5 hours. i’ll think about it again tomorrow. Thank you very much,
Default characters (First & Third Person template) use Character Movement Component (CMC) which utilizes client-side prediction. This requires players to input, server duplicates the movement (loc/rot/states), then compares. If the loc/rot are not within margin of error (float precision errors + buffer) the server will correct the client. Otherwise it sends an ack.
Inputs for movement and actions are sequential. The server should be able to get really close to the same start/end for traces and a really close hit result.
IF you are getting results like the following. You aren’t using the correct references and data.
For camera locations on the server you should be referencing the Camera Manager.
For Rotations you should be using Base Aim Rotation (preferably) or Control Rotation.
And yes, I’m aware that the animations aren’t correct, I haven’t integrated them yet, but that doesn’t change the fact that the server always rotates with the player’s movement, while the client doesn’t. like the client, it’s supposed to be the same for both.
The basic problem was that I followed a tutorial that set up the kammera for a FP character without thinking. Then “Orient Rotation To Movement” was switched off when moving and activated again when the movement keys were released. Of course, this should also be done on the server if you want the rotation on the server and the client to stay synchronized. So what do we learn from this? I would say even if you think this is a very well done tutorial, you should always think about what is happening and do I need to adapt this step to my project xD
You cannot use FP Kammera for the server.
Why not? It’s working quite well at the moment. I’m not saying that what you’re saying isn’t true, I’d just like to know why it should be like that.
For world location you have to get the cameras location from Camera Manager. Controller → Get Player Camera Manager → Get Camera Location
the problem is that i have two cameras and i don’t want to run the trace from the active camera. Of course, if you can tell me how I can access a specific camera without setting it as active, I would use it.
For rotation you should use Get Base Aim Rotation. Get Base Aim Rotation → Get forward Vector
and what is the advantage of that?
don’t get me wrong, i’m always open to suggestions and tips on how something could be done better. i’m just not a fan of being told you HAVE to do it this way. Many ways can lead to the goal and if one way works you have to say why the other should be better if you say you should do it differently.
Camera reference on the Server uses it’s spawned location (Z). See my pics above.
When you crouch, prone etc the camera location on the server stays at the spawned location height.
Using camera manager will get you the correct location regardless skeletal mesh pose.
Base Aim Rotation will always match the clients camera rotation. Camera Rot will not under certain situations. Again look at the pics I posted above.
Control Rotation is based on the capsules rotation. It’s accurate, but will not always match up with the camera rotation.
Hm okay, I also have no problems with squatting or jumping when I use the camera, as you can see here.
In your post above you wrote that if you have such deviations as in the picture then…
but since i don’t have them, why do i have to use the camera manager in your opinion?
it may be that i will encounter this problem later on, but at the moment it works as you can see in the video.
i also said that i can’t use the camera manager because, as far as i know, it only returns the active camera, which i can’t use in this case. however, if you know a way that i can address an inactive camera via the camera manager then i could of course also use this way.
As far as the “Base Aim Rotation” is concerned, I haven’t noticed any difference so far, no matter how I’ve moved. But I’ll save the page and if the worst comes to the worst I’ll have another look.