How can i set variable from client to server?

I want to make a net working chess game, but the piece has many own propertys,
like attack point,health,move range,move direction .etc
Currently, I have a problem for move pawn.

I use listen server , only two player, client and server.
I want to set the pawn location in client, and server can see it change.
The value of location can be change by player.
I’ve seen the networking totorial, but the problem does not solve.

Now i can do this in server and client can see work.
In turn, not work.

Is there any way to solve this problem?like variable intercommunicate, or when client call server func then server get client’s variable.

I’m Taiwanese, my english is ugly, Please forgive me.
If you have a part that you do not understand,tell me, i will try to explain.

thanks a lot

我想做一個可以連線的棋盤遊戲,但並不是像西洋棋或象棋一樣規則簡單。
比較像戰棋,棋子擁有一些屬性,想是生命值、攻擊力、移動方向、移動距離、技能等等…
目前我遇到一個問題。

我是使用listen server來做,連顯時只會有兩個玩家。
我想要在client端設置棋子的位置時server端也能看到同一顆棋子改變位置。
位置的值是可讓玩家控制的。
我已經看過youtube上面的教學影片與unreal engine 4 doucument - networking,
但問題還是沒有解決。

目前我只能做到server控制棋子時client可以看到。
但反過來server卻看不到client控制棋子。

請問有方法可以解決這個問題嗎?像是值的互傳或是當client呼叫server的函式時server去要client的變數之類的。

我是台灣人,請原諒我的破英文,如果有不懂意思的地方,請告訴我,我會盡量解釋到你能了解。

在此先感謝各位。

What is the current way you are doing this?

With a client server setup two things are very important.

  1. Make sure all variables and actors of yours which are important to both players are properly replicated. Variables have an option in the details panel where you can set them to “Replicated” and actors also have options in the “Class Defaults” to “Replicate”, “Replicate Movement”, etc.
  2. Make sure everything is done on the server. When you create a custom event you can select in the details panel “Run on Server”. Make sure you always call a custom event with this property when you spawn or move an actor or change anything because only if the server does this it can be replicated to the clients. The clients won’t by default send everything to the server.

If this short explanation doesn’t help could you show us how your current BPs look like?

Hi Rrasio.

Thanks for your Reply. Your Answer is correct.
I forget to remove this post after the question solved.
I’ve probably understood how does the network event work after i read related documents.
The actor blueprint in level can not trigger network event when the event is implement in this.
I does not setting the “default pawn”, but i use the playercontroller to implement network event.

Thank you :smiley: