Hello everyone; I’m a bit new to UE4; I’ve been working on my project for about 3 months now, using the internet as my teaching guide. I’m trying to make an in depth multiplayer animal survival game, and I’m having a bit of issues with replication. At the moment, this is all with the Visual Blueprint System - I am not familiar with coding; although it is on my to do list… eventually.
Anyways, here is my scenario:
I have the main creature Character BP. These characters have food and water meters that decrease with time. This Character BP replicates correctly across the network. At the moment I am starting with a carcass, that when hit with a LineTraceByChannel calls a function in the Character BP to add Hunger to the using character’s hunger bar.
However, the error arises with the carcass. At the moment, I have the carcass as an Actor BP (obviously non-player owned), that is stationary on the ground. When the carcass is hit by the same LineTrace, the Carcass Food amount lowers - with morph targets decaying, eventually leaving only a skeleton once the Carcass Food variable reaches 0. These functions work fine on client side, but I cannot for the life of me figure out how to replicate the Carcass Food value through the server. (IE Creature 1 eats from carcass, leaving 50/100 food left. Creature 2 approaches, and the carcass is 100/100. I want the carcass to retain this amount to all connected clients). No matter what I have tried, it just won’t replicate the Carcass Food value to the server.
I started by having the deplete carcass functions in the Carcass Actor BP, but I’ve moved them to the Character BP, and now to the PlayerController, in a desperate attempt to get it to replicate properly, which I have had no success. (I read that an actor not owned by the player cannot execute server commands.) The variable is replicated, I have set up RPC’s to try to set the variable through the server, but it just doesn’t seem to work.
How would one recommend I go about doing this?:
(Character BP interacts with Non-Actor BP, and deplete a variable from it, server wide.)
I know this has to be possible, unless I am going about it the wrong way. I feel like this is freakishly simple, but I have embarrassingly been stuck on this issue for 1 week.
Thank you for any help in advance, I really appreciate any insight!