I’ve been working on a multiplayer project for a while now with knowledge that I’ve just been getting from forums and tutorials, so I’m quite the novice.
I currently am using a method for this that I got from another user on here who has helped me a lot but I’m running into a problem with this where changes aren’t replicated to the client, and the client cant interact with the object.
This is the code for the interaction and the event that fires off in the object when interacted:
I cant get a video RN but basically what happens is the server player can interact with the interactable and change spotlight colour but the client literally does nothing when they interact with the object and they cant see the servers changes
Looking over both tutorials now and wanted to ask; does the code need to be set up any different? as I am using a listen client setup.
Main reason I ask is because the beginning of the tutorial says to make the interact only execute for clients and i assume that wouldn’t work for a listen server with a player acting as the server.
I’ve discovered that what’s happening is when the client player calls the RPC for the line trace the server trace is spawning from the hosting players (server) world location. still unsure of a fix though
Looked through the comments and didn’t really find much of use, the main problem that I’ve now identified is that the world location for the camera will always default to the hosting player’s camera location when it is called through the server.
There is only one time where this doesn’t happen and that’s by removing the authority check for world location entirely and just using the camera component’s world location. Problem with this is that it doesn’t update for the client when crouched, so when the client crouches the trace stays at standing height, this makes no sense because the players camera location is moved down around 50 units when crouched.
ok, I made a macro that checks the net role of the clients and now i get the world location by getting it from the player controller camera manager, new problem is that now it only uses the Client 0 (host)’s camera location no matter what client is interacting. I had this problem before and don’t know how to differentiate the two.
video of the code and the problem, server window is the left one, the trace always starts at the server player location when using the player controller setup, as for the pie mode im just using the new window one (if thats what you mean, if you mean a debug mode i’m not using one)
First you absolutely need a clean reference to the controller for the given proxy executing the trace logic. I have no clue what your approach is to getting a controller reference, but it should not be Get Player Controller (index). Any node requiring a player index is for client-side only usage. They will always fail in a multiplayer game… Listen AND Dedicated.
You’re better off using Get Controller from the pawn class. This returns a generic Controller reference. From here you have 2 choices.
Cast the return to Player Controller, then get Player Camera Manager → Get Camera Location
Switch has authority does work on a listen server environment in general. Where and how it’s used is key. Understanding that it’s looking for network authority which is always the server… Dedicated, or listen host.