How do I fix this issue with clients and enabling input on an actor

Hi I am new to unreal engine and I was wondering how to fix an issue. When enabling input on my actor and starting the game the line trace affects another client instead of the user who triggered it can someone please help me fix this?
this is the image of the bp its also a child blueprint

1 Like

Hmm, I do not seem to understand what you mean by

line trace affects another client

because it is not connected to anything and the hit result is not used for anything. Do you mean the line trace hits the player? You can simply do this:

From ActorsToIgnore, you can come out and say Make Array, and by connecting Self to it, you will ignore the actor who is doing the linetrace. Also, if the linetrace is not hitting the enemy actor, be sure to set the Collision visibility to Block on the character, like so:
image

I’m still not sure what you need help with. Read up on linetraces and watch a few videos on YouTube. Doesn’t have to be UE5, it’s the same logic. It seems weird at first but I’m pretty sure you’ll grasp it easily!

By client if you mean as in Multiplayer, I would never suggest trying to learn Multiplayer/networking logic before understanding the basics of the engine. Anyway, hope this helps somehow!

What i meant was that when using my input action shoot instead of starting a line trace from my gun it would start a line trace from the another clients gun instead of mine I was wondering how to make it so that when I use my input action it would create a line trace from my gun to wherever but instead every time I use my action it will use the opposite client window/gun to start a line trace and not start a line trace from my window/gun this will still do the same thing if I switch to the other client it will line trace from the opposite window if I set the game to 1 player than it will will line trace from me

Oh OK… So you are trying stuff on Multiplayer. So to put it simply, getPlayerController is never a good idea if you are planning to do Peer to peer stuff, basically host + client logic. However if it’s going to be splitscreen game, you can simply play with the getPlayerController index to achieve what you want. But I’m not the best to comment on that.

In any form of multiplayer you are dealing with more then one player and each player has a specific set of object.

Each player joining the game has a UPlayer object made (which is not accessable in blueprints) then from that, the PlayerController is made which is simply the representation of the player control interface.

Before diving into multiplayer, you must understand Unreal’s set of classes. You should already be aware that PlayerController is the one possessing the pawns in the world and controlling them by feeding with control data from player. Each player has its own controller and each player possesses a pawn that is controlled by the player controller.

There is only one Game Instance and only one Game Mode, which aren’t associated with any player, and used to manage all the players in the world. In networked games GameMode exists only in server.

Now about the index input, you should use that only if you really want to address a specific player. In your case, you can simply play with the number to understand the logic. However, in most cases you should access those things via relation, for example from an overlap event with a pawn, which will return you a actor that caused that specific event. Then you can check if it’s pawn, if so, you can check if it is possessed by any player controller and you can get that controller from Get Controller node.

I can write a lot more but I really don’t want you to get confused. Just take it easy, start a fresh project and follow some tutorials about FPS/shooting/receiving damage/dealing damage/etc. and then slowly get into networking. However, if you’re gonna insist on learning networking first, no judging, best of luck, here’s a good e-book:

1 Like