0
\$\begingroup\$

I have variable=count(integer) in a Character Blueprint.
I want to increment the variable when user presses the 'R' key.
What do I so in the Blueprint that variable remains the synchronized between the server & client?
For example:
In server- 'R' key pressed 3 times so count value should be 3.
In client-'R' key pressed 4 times, so then the value should be 7.

\$\endgroup\$

1 Answer 1

0
\$\begingroup\$

If I'm understanding you correctly, you have a variable and you only want it to increment once when the client presses the R key but what's happening is it is being incremented on both the server and client, doubling up the count.

To get around this, you need to use the Switch Authority node

Switch Authority Image

Make sure the variable is replicated and only allow it to be incremented by the server.

\$\endgroup\$
2
  • \$\begingroup\$ No,Both server and client can increment the variable..how to do so that when server increment the variable..that value will also store in client variable ...visa-versa for client. \$\endgroup\$ Commented Nov 6, 2020 at 10:08
  • \$\begingroup\$ Why would you want both server and client to be able to increment it? That could allow for cheating. \$\endgroup\$
    – Stephen
    Commented Nov 6, 2020 at 11:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .