x

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"

Step-by-Step "Tutorial" for client-to-server Replication needed

Hello,

since nobody seems to answer my previous question, I go one step back and ask for a more simple solution to a problem. I got more understanding in my previous approaches, but I still cant really figure out the right way to accomblish it.

So what would help me now would be a really small step by step tutorial for a variable replication from client to server.

All that I need would be a simple setup like e.g. the following:

Bool Variable (test) = false

Begin Play -> Delay -> Set to true (so far I can do it of course :D)

And then exactly what I should click to make the state of the variable change on the server too. What event/function to create, name them (example), how to call.

I know, this is a very special request for the answer hub, but the asked issue is pretty simple I guess, so it would help me a ton, if somebody could provide me with a step by step and some pictures maybe.

Thanks so much!

Product Version: Not Selected
Tags:
more ▼

asked Oct 26 '14 at 08:18 PM in Blueprint Scripting

avatar image

Hermi1988
31 6 11 13

avatar image lordconstant Oct 26 '14 at 11:56 PM

In the blueprint editor create a new bool variable and in the bottom left you will see a dropdown called replication, set it to replicated and you are done.

https://www.unrealengine.com/blog/blueprint-networking-tutorials

Short tutorial on the unreal blog as well.

Hope this helps ^^

avatar image Hermi1988 Oct 27 '14 at 05:34 AM

Unfortunately this only replicates from server to client. I need it the other way around and read, that this is a little more complex. With rpc to call and such. I need help there, but thanks :)¡

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

3 answers: sort voted first

Okay I got the theoretical part all figured out. I know how to connect all the dots to make the magic happen.

BUT

My RPC gets not called, because I am not the owner apparantly.

I have selected to start with Default Pawn to "None" so at Begin Play I am basically "nothing."

The Blueprint above is on a actor called spawner, which is placed inside the level.

How would I accomblish to "own" the spawner blueprint, while being nobody so to say?

P.s. Since I do not know how this question gets updated in the answer hub, i will start a seperate question soon.

more ▼

answered Oct 29 '14 at 09:12 PM

avatar image

Hermi1988
31 6 11 13

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

Whats the context of this question? What thing sets the bool and why should the server use the client value?

Normaly you would make a replicated function. Thats a custom event. You can set the replicate to "Run on Server".

This is called by a client and runs on the server. So you could make an input for this event (bool) and pass the bool. Use a "authority" node to make sure the client only calls it. Then on the server side of the event, use the variable you passed to set the variable serverside.

A custom event always has a red node and a blue node. If you create the event, you get the red node. Here you set the replicate option and add inputs. Now you can search for the event like every other node and use this second node (" blue") to call the event. So the begin play goes into a delay node then into a athority node, then on " is authority" into a set node that sets the replicated bool directly and on the client exec you take the custom event and mark the bool input with true. At the other end of the event you take the bool and again set the bool.

That should be all. Cant give you pictures because im on phone.

more ▼

answered Oct 27 '14 at 11:55 AM

avatar image

eXi
6.8k 333 185 468

avatar image Hermi1988 Oct 27 '14 at 04:37 PM

For the context thing,

I have 3 UMG Buttons, which are supposed to select one out of three players.

The basic Idea is select one, let the selected one be spawned by the server and then possess it on client side.

Now I cannot get a UMG click event to do anything on the server, so the Idea was to set a boolean on the server via click and then let the server do the spawning based on the bool.

But I cant get the bool set on server side.

I read through your comment, and this is more or less the info I gathered in all the forums and answers, but I just cant get it to work. Thats why I would have appreciated a pictured step by step for just the boolean, cause the rest I could manage..

avatar image Hermi1988 Oct 27 '14 at 04:41 PM

Okay here is my latest progress. I tried to follow your instructions, but I am still struck.

Basically, on 1.) the Blue "Replicated Mage Spawn" gets called via a button pressed through UMG in another blueprint. This works for sure. But after that I am stuck. I have the manuall created Bool laid out and I created an input bool in the event. I marked them on the screen accordingly. Maybe you could do a small paintover? :-)

alt text

rep2.jpg (235.3 kB)
(comments are locked)
10|2000 characters needed characters left
Viewable by all users

how would you replicate a float from a client to the server and any other clients? when I use a custom event set to "run on server" the float just stays at its default value no matter what, I have tried putting the float in as an input in the custom event but that comes through as zero every time or if I plug it strait into what it is meant to be doing inside the custom event then it uses the default value but doesn't listen to what the client is doing.

more ▼

answered May 15 '15 at 08:39 PM

avatar image

The Cheese Dragon
191 8 11 34

avatar image vanlacke May 15 '15 at 08:50 PM

Did you replicate the variable?

avatar image The Cheese Dragon May 15 '15 at 11:05 PM

yes I did...

avatar image eXi May 16 '15 at 12:19 AM

Is the number 0 before entering the event?

What class are you working in? Not all classes allow Run on Server.

avatar image vanlacke May 16 '15 at 12:29 AM

Can you explain what you are trying to do? Simply set a float variable on all clients? Like what.. HP? Score?

It's easy. You need to run a custom event on server, then from the server run a multicast event with will set the variable on all clients.

avatar image The Cheese Dragon May 16 '15 at 12:50 AM

I am getting the relative rotation of the camera arm and braking that into 3 floats, I then set two variables with the pitch and yaw, these variables power the aiming offset in my animation blueprint. The aim offset points the characters head (the character is a dragon) in the direction you are aiming the camera.

If I don't use custom events it works perfectly on the client but other players don't see it, I have tried setting the variable in a custom event set to "run on server" and then the server can see the aim offset working but all clients see it aiming north (world x or something I think) rather than in the direction the camera is facing.

avatar image vanlacke May 16 '15 at 04:33 AM

I just tried to add multiplayer aim offset and I got it to work.. Care to show me your blueprints to see if I can help?

Maybe you should make a new question regarding this

avatar image The Cheese Dragon May 16 '15 at 11:08 AM

So here is a picture of the bit to do with the aim offset, I'm setting the rotation of "look Direction" every frame I don't replicate that (when I've tried it stops working altogether) The event called update look angle is set to "run on server" I have tried putting it through a has authority node as well but that makes no difference. any ideas, if you need to see the whole thing I can send it later.

alt text

problem.png (134.4 kB)
avatar image vanlacke May 16 '15 at 07:00 PM

Okay, I think I see the problem.

Add a branch right after Look event, and use "Is Locally Controlled" as the condition. If true, then Update Look Angle.

Let me know if it works

avatar image The Cheese Dragon May 16 '15 at 08:01 PM

Excellent! yeas it works :) thankyou

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
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