How do I access my Player Camera Manager (replicated (listen server and client)) in UE4 Blueprints - unreal-engine4

When I try to access the location of my Player Camera Manager on the server it returns 0, 0, 0.
I think that I tried every option on setting the Player Camera Manager respectively the Player Controller in all the replicated options. To be clear: At first, I used my common sense but after a week of failure I tried every combination with no success.
As an example: Here is how I tried to access the Location and the forward Vector for a Line Trace
I also tried to set the Camera Manager as a variable (I tried both server and client) and then access it on the server.
Does anyone have any ideas on how to fix that?
Any help is much appreciated.

APlayerCameraManager is not an actor that replicates, so I'd expect that blueprints to only work on the client. You'll have to replicate the values you need back to the server.
If you're making a first person game APawn replicates a variable named RemoteViewPitch that may be enough depending on what you're doing.

You can do it just make an interface function with input the information that you need from the manager then go to character and assign that to it then go to the manager blueprint and get the information and use controlled pawn to get ur player ref and call interface function

Related

Netcode Behaviour index was out of bounds. Did you mess up the order of your NetworkBehaviours? Unity Netcode for GameObjects

So I've been following some tutorials online and have been trying to create a multiplayer 3D game, and so far, all I want to do is for two clients to be able to connect to a server, spawn their players (spheres), and move their spheres around and into each other, causing collisions.
I have created a player movement script to handle input - just simple WASD and space-jump movement.
To handle the networking, I followed Tarodev's Netcode video to set everything up.
Here is where the problem begins. Using ParrelSync, I run the game on one editor and a clone on another. I then use a GameObject with the NetworkManager script to start a host on one editor, and a client on the other. Upon connection, the client and host both spawn players, but then the problem begins. As the client's player starts falling down, the host's editor starts experiencing errors and warnings. As mentioned in the title, here they are:
[Netcode] Behaviour index was out of bounds. Did you mess up the order of your NetworkBehaviours?
[Netcode] Network variable delta message received for a non-existent behaviour. NetworkObjectId: 2, NetworkBehaviourIndex: 2
I did a bit of digging and found that the error was being thrown by a function in the NetworkObject script, but I couldn't really understand why or how to fix it, hence this post.
Errors are only thrown on the client when the host moves its player, and errors are only thrown on the host when the client moves its player. The transforms of the players are not being transmitted between host and client at all, despite the player prefab having a Client Network Transform script, and a NetworkObject script.
Here is the link to the code if you want to reproduce the error or understand it better: https://github.com/XR101/Sumo101
Any help would be appreciated as this error is driving me insane.
It seems to me like this could be an error in the order of components on your game objects.
If there's only one component on each object, then make sure you're instantiating them correctly on the server via NetworkServer.Spawn
If you're sure you've done those things, then it's probably a component mismatch due to PlayerMovement and PlayerMovement2 being used. I have zero experience with Unity's networking stuff but it seems from the docs that they're intended to communicate with a NetworkBehaviour of the same type.

Unity Photon Error Close Connection problem(Help)

I was making a game and I wanted to put a Kick System in the game, but I encountered such an error, can anyone help?
CloseConnection is disabled. No need to call it.
UnityEngine.Debug:LogError (object)
the only solution is to set Photo nNetwork.EnableCloseConnection to true...You have to call it when the game starts or elsewhere but it can't be synced across clients because it is not associated with the server.

Trying to understand Unreal Engine 4 replication

I'm trying to understand how to call events between client and server. My goal for now is simple. I want to create anything that is interactable for 2 players.
Easiest thing I could think of was cube that is switching color when clicked. So I did create actor based blueprint, checked "Replicates" and AlwaysRelevant to be sure. PlayerController is also replicated and there is no pawn needed.
Color change blueprint:
SM is just static mesh if that is important. As far as I know client have no authority to call multicast events so I wanted to push it through server but it stops there. Called from server works as expected and color itself IS replicated to client, however client cannot change color himself.
What am I missing in this concept? I've watched like 5 videos about replication and I started to think there is something missing which is either obvious for everyone but me or their examples do not need things I do here.
As you've found out, a player's client can not directly call server RPCs on actors which the player does not own. Calls must be routed through that player's PlayerController. The server copy of the player's PlayerController can then call server methods on server-owned actors.
Another issue is that you seem to be using both RPCs and replicated properties for the same purpose. Unclear to me why changed is replicated since you're modifying it in a multicast event which normally runs on all the machines. This is a recipe for hard to find race condition bugs.
Replication in Unreal is definitely one of the harder concepts to get the hang of. The resource that helped me the most is this guide which while quite dated, is both comprehensive and to the point.
You can't have it in PlayerController, it's got to be in a Pawn, or if not, in PlayerState, or it won't get shared to other clients.

Resetting the global origin in Unity?

I'm creating a Unet application, where the server is responsible for spawning units, and the clients (obviously) see the units and their movements. Clients can spawn stuff via server commands, and typical interactions.
What i'm hoping to allow, however, is each client to redefine their global 'origin' point. So if i'm in the world and i see it in front of me, i'd like to be able to turn around and determine that "hey! that point over there is now the origin", and have all the components move to that new location (which should be handled automatically by the NetworkTransforms).
Does anyone know how i would be able to accomplish this? Or even implement some sort of NetworkTransformOffset script based off the network transform?
Yes....
By moving everything by an amount equal to -1 * new_origin yourself.

How to display each player's score [Network Manager]

I am working on simple multiplayer (2-player so far) game based on built-in Network Manager (based on this great tutorial https://unity3d.com/learn/tutorials/s/multiplayer-networking) and I have absolutely no idea how to solve my problem. Every tutorial I found about scoring systems was focused on local multiplayer game (not using Network Manager).
My question is:
How to display both players score on each player's UI in format like [Player1Score : Player2Score] if I store player's score in their instance of player's prefab (as a field).
I would like to display the scores in any way, as separate or as one appended string (UI text).
Any help and ideas are welcome!
Cheers!
Well basically , as far as i know , you firstly need a controller (server side) which keeps the score.
Then through Syncvar and RPC you can propagate to clients the score you need.
The logic there is at your choice , for example you might use delegates everytime a point is scored (it will depend on your game), and synchronize the variable.
https://docs.unity3d.com/Manual/UNetActions.html
I do not know what your case is? But can I suggest using Socket to transfer data between client and server. From there it is possible to display each side's scores to the opponent.
Via https://learn.microsoft.com/en-us/dotnet/api/system.net.sockets.socket?view=net-5.0