Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

How to replicate a Non-Player Actor integer/variable value to server/all clients?

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!

Product Version: UE 4.19
more ▼

asked Sep 15 '18 at 02:59 AM in Blueprint Scripting

avatar image


(comments are locked)
10|2000 characters needed characters left
Viewable by all users

0 answers: sort voted first
Be the first one to answer this question
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question