Download

HELP: Line Trace difference between Server and Client

Hi @all,

I developed a line trace function in order to add items to an inventory array. As a server, it works, but as a client, the line trace function seems to ignore that i reduced Z-Value -40px.
Any ideas what’s wrong here?

Cheers/Lukas

903ee799e57788f4629095ab99623ae027c2d7d5.png


The only thing that pops into my eye is that you are using “GetPlayerCharacter 0”. You would want to directly get the Capsule Component, since you
are already in the Character.

Otherwise the Call will be based on the Server and Client controlled Pawn. The Server Controlled Pawn (GetPlayerCharacter0 called on Server) is not the same as the
Client controlled one (also GetPlayerCharacter0, but called on client).

But if you take the CapsuleComponent directly, it will be the one in which the function is called. Server the Server Version of the Clients PlayerCharacter.

The problem is, that “get actor rotation” ignores the Z rotation which results in a Line trace which changes on the XY axis, but not on the Z axis. And get forward vector requires the actor rotation, it´s just “included” in this node. For your Client, cast to ThirdPersonCharacter and use “self” as the object (if that´s wrong, i´ll have a look at my BP when i´m home). Drag the “As ThirdPersonCharacter” pin off and add a “get Camera” node. It´s important that you don´t just drag the Camera from your components tab in the Viewport! Get it´s World location for the start point. Also, drag from the Cast node the pin off and search for “Controller rotation”. This will include all 3 values! Then just create a get forward vector node and connect it to the Controller rotation. Sorry if i didn´t explain it clearly, i´m not a native english speaker.

Why should he take “Self” and Cast it? x) If he can take “Self”, he is already in the correct Blueprint. Se he can just get the Component etc directly.