Forward: I have completed YouTube tutorials 1-83
I created an actor blueprint, PlaceWall, which contains a wall static mesh and for some reason an audio component I’m just noticing now, no idea why it’s there.
Here is the defaults panel. I have replication enabled.
Here is the wall’s event graph.
The wall is implementing an interface, “UseInterface”
Both functions, OnUse and OnUse - Holding have a character input pin.
When the character presses “E”, it runs a “InputAction” event. Here is the event graph for my character using the InputAction event
The basic functionality is, if the player is holding an object, activate that object’s OnUse - Holding event. If they are not holding an object, run a trace from the camera to see what they’re looking at. If they’re looking at an actor within 200 units, attempt to run the actor’s “OnUse” event.
So, the first time through, the player walks up to the wall, presses “E”, the event graph activate’s the walls “OnUse” event which triggers the character’s “SetHoldingObject” event, which is this:
This checks to make sure the character is not holding an object. If they are not, assign the object to the character’s “HoldingObject” so I can reference it later, set “Is Holding Object” boolean flag, attach the object to the player’s camera, and disable collision.
Now, if the character presses “E” again, the “InputAction” event fires, sees an object is being held, and runs the wall’s “On Use - Holding” event which calls the “Place Held Object” event on the character.
This detatches the object from the camera, re-enables collision, and clears the held object and boolean variables.
In single player, this works exactly how I want it. You press “E” on the wall and it is attached to your camera, you can see it in front of you. It stays attached until you press “E” again and then it is fixed in place where it was when you pressed it.
If I simulate multiplayer, different things happen for both the client and server.
Server: Server picks up the wall and runs around. The client can see the wall moving, and it is almost perfect except that the wall should also move when the camera moves (camera rotates yaw/pitch with mouse up/down, character moves x/y with WASD). So if the server looks around without moving the character, the client does not see the wall move.
Client: Client picks up the wall, server does not see the wall ever move. Client can’t move through the place where the server still sees the wall.
Edit: I’ve fixed the issue where the server’s camera rotation was not synced by creating a variable for it that gets replicated. However, still, anything the client does never makes it to the server.
I would really appreciate some input on this.
Thank you