I’m trying to create my first multiplayer game using the THNK extension and I’m trying to have UI elements displayed for the players as simple as menus or inventory that are hidden to other players.
Apart from not using the sync behavior , how does one create an object that doesn’t appear to all the players?.
I want a menu to open when the player distance to an object is <125 px.
When I put these conditions and actions on the client code, it apears to everyone. (Only the player object has the sync behavior)
Same thing happen on the server code.
So what’s the trick for triggering event for a specific player only?
Would you mind sharing your events? THNK never syncs something unless you tell it to…
Maybe you check if any player object, including the other players’, instead of just your own? For that, you have two solutions:
- You can determine in the server events when a player is near enough to trigger that dialogue, and instruct that specific client to open the dialogue via a scene PlayerState variable
- Use an object playerstate boolean variable to tell each player which instance they own. Check and pick the instance with that boolean variable set, and only show the menu if that instance meets the conditions for opening the menu.
I actually tried to use a playerstate boolean variable but I think I’m using it wrong.
Here is what I’ve tried. The result is that the menu is created and appears on the server preview, not the client’s.
I have trouble understanding how to assign instances of objects to a specific player.
And once it is done, should my “distance between 2 object” condition and menu creation action be in the client events or server events?
You are doing it right, or better said, how it should be done in the future. Right now, on the server side, you need to do
PlayerState[THNK::PickedPlayer()].NearWater instead of
PlayerState.NearWater. In the future, THNK will correctly interpret
PlayerState.NearWater as the
PlayerState of the currently picked player automatically.
It works! The menu opens and the other players don’t see it.
However it seems that the menu opens for the other player as soon as they do anything (even if not meeting the condition to open the menu on their side).
I’m going to work that.
Thank you very much!