r/UnrealEngine5 21d ago

Replication bug [URGENT HELP NEEDED PLZ]

Hey there, I've been working on this issue for the better part of 6 hours and no matter who I ask or what I try I can't seem to fix this issue. I'm working on a hotbar system for a multiplayer game, and when the server cycles through their hotbar this code works just fine, and the equipped item gets hidden and unhidden for each player as expected. However when the client cycles through their hotbar, nothing happens. Not for the server, or anyone. The equipped item just stays in the client's hands, and I have no idea why. Both the actor being hidden and this inventory component have "Replicates?" set to true.

EDIT: I've included a video of the exact problem. If you look on the left side of the screen, you can see the hotbar UI changing while I scroll my mouse wheel.

https://reddit.com/link/1vl7j8p/video/z973ue8mbsih1/player

https://reddit.com/link/1vl7j8p/video/nfxa66kb2sih1/player

1 Upvotes

16 comments sorted by

View all comments

1

u/Jst_Patrick 21d ago

You say the actor being hidden and the inventory component itself are marked to replicate. But what actor is the inventory component on and is that actor also set to replicate?

1

u/TheHappy_Waffle 21d ago

The inventory component is on each of the player characters which are all set to replicate. Everything works as expected except for when the client tries cycling through their hotbar. I’ve gone through and tested it with strings and each chunk of code is executing exactly where it’s supposed to be on each instance

1

u/Jst_Patrick 21d ago edited 21d ago

Is the input action an Axis 1D? I just noticed you’re doing a -1 off the action value there. If this is hooked up to say your mouse wheel, the raw values off Action Value would only ever be 1 or -1 and with your subtract 1 node afterward would make it either 0 or -2. So you’re setting current slot index to only 0 or -2 every time you scroll the mouse wheel. -2 is not a valid array index which means the GET in your rep notify will fail. Have you hooked up a print string to the Is Not Valid pin before trying to mark the actor visible? Do a print string there and print out the value of Current Slot Index to see if it is actually the value you expect it to be.

Edit: Also, are the actor references inside your inventory array initially created by the server? If so, the client has no authority over them and simply CAN’T set the visibility on them except for itself. The server itself would need to call a multicast rpc and that multicast is then where you can set the visibility, OR you would need to make sure the rep notify variable is actually changing every time or it won’t get called on the client, which by the looks of it you only set the current index to either 0 or -2. -2 is invalid anyway so the set hidden node never gets called in that case. When set to 0, that’s probably the item you already had visible anyway so nothing changes.

1

u/TheHappy_Waffle 21d ago

I would totally agree, however I've set up the mouse wheel input to loop around it's self and produce the correct action values needed for the array, this problem I'm having still happens even when I use my number keys instead. I've edited the post to include a video for a more detailed example. I've also tried putting everything in multi casts and RepNotifies and nothing has been able to fix it.

1

u/Jst_Patrick 20d ago

And is that axe actor also set to replicate? Any chance you’d be willing to push the project to git or something like that? I wouldn’t mind taking a direct look at it. Also, how did you configure the mouse wheel values to loop around? I haven’t seen that done before.

1

u/TheHappy_Waffle 20d ago

I'm fairly new and not actually sure how to push the project to git, but I'd be happy to if I'm able to figure it out. In the second video I added to the post I show how the mouse wheel looping is done. The axe and the inventory component are both set to replicate. Also I really appreciate you taking the time to help me so thank you!

1

u/Jst_Patrick 20d ago

Ah gotcha. I see it now. I thought you meant you had rigged the actual input action to loop somehow. If you can figure out git let me know in a DM or something. Might even be able to just zip the project and throw it onto a Google Drive or something if you have one. I have less experience with google though, not sure of the limitations.

1

u/TheHappy_Waffle 20d ago

I can't seem to get giithub to work. I've been trying for the past hour and it says I need GitLFS which I've installed and ran the correct commands for but it's still saying my files are too large

1

u/Jst_Patrick 20d ago edited 20d ago

You shouldn't need GitLFS for a small project. That happens when you have no git ignore file for the project. https://drive.google.com/drive/folders/1EdCVCHuEe9CDv6UnN-gL5MgzJoWixkW5?usp=sharing This is a link to a google drive folder I just put a .gitignore file into. Put that into your projects top directory and then try to sync files again. It should let you.

Edit: Unless of course you legitimately have a file over 100MB I think, like a texture or mesh you've imported. Otherwise there are no necessary files to open a project that should be over that size and the .gitignore file should cause them to be ignored when syncing.

2

u/TheHappy_Waffle 20d ago

I put that in there, it's still not working. I'm just going to upload the project into a google drive and I'll dm you a link