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"

Correct way to handle server "while busy" check in Blueprints

I'm implementing a card game and need help determining when the server is "busy" on the client.

The turn of events is first the client clicks on their deck (through a line trace), calls a server event which draws a card, and once the event is complete then the client can repeat the action. Of course, if the client clicks before the drawing event is finished, then nothing happens.

Here is the best logic I could think of:

  1. Through a trace hit on the client side, the client clicks the deck.

  2. The client's "busy" variable (not replicated) is set to true.

  3. The client calls a server event where the "busy" replicated variable is set to true.

  4. In the server event, the client "busy" variable is set to false.

  5. When the server event is finished, the "busy" replicated variable is set to false.

  6. The client's trace hit can now fire again since both variables are set to false.

Is this the best way? I'm sorry if I'm simplifying this too much, but I just need the basic framework of a client to server event where the client can't continue until the server is finished.

Any feedback is appreciated. Thanks!

Product Version: UE 4.10
more ▼

asked Jan 01 '16 at 12:59 PM in Blueprint Scripting

avatar image

25 7 7

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

1 answer: sort voted first

What you can do, for a more direct approach, is use server and client events to set the busy status.

  • Client clicks card via trace

  • Client tells server it has clicked the card

  • Server sends an event back, 'click success' (set busy on client) or 'click failure' (warning)

  • If success, server deals with click

  • Servers finishes, sends 'your turn' (or whatever) (unset busy on client) event back to client

These need to be reliable events. Relying no replicated bools isn't a good idea. They may be replicated slowly and inconsistently.

more ▼

answered Jan 01 '16 at 01:05 PM

avatar image

1.7k 81 28 81

avatar image uw19 Jan 01 '16 at 03:03 PM

Yeah, I was having that problem with using replicated variables. So when the client tells the server it has clicked a card, that's an event, right?

avatar image TTaM Jan 01 '16 at 03:05 PM

That's correct, yes.

avatar image uw19 Jan 01 '16 at 03:06 PM

Awesome, I'll try this out. Thanks for your help!

avatar image TTaM Jan 01 '16 at 03:09 PM

A slightly better way would be to set the busy flag when sending the initial event to the server, rather than waiting for a response. Then the click failure event removes the busy flag.

avatar image uw19 Jan 01 '16 at 03:40 PM

Where is the busy flag stored? In the character blueprint that is using the trace or in the game state, perhaps? And if it needs to be replicated, then that seems like the same issue as earlier.

avatar image TTaM Jan 01 '16 at 03:51 PM

You don't need to replicate it. The server/client events deal with that. Store it wherever you like. Wherever makes sense for you. I will say, putting it on your character, player state or controller will make it easier to deal with events. Those are the only 3 objects you can send server events on.

(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