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"

How to replicate an event to a specific client only?

Hi,

I have a treasure chest where, if opened by a specific pawn, I want that specific pawn to only see the chest opening animation but other nearby clients including the server should not? I still want the server to give the client the items to prevent the cheating but visually-wise, the player on the server shouldn't know that the client opened the chest.

Thanks!

Product Version: UE 4.21
Tags:
more ▼

asked Jan 30 '19 at 03:34 AM in Blueprint Scripting

avatar image

rbx
8 3 1

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

1 answer: sort voted first

Client that you only want to replicate within an event can pass PlayerState.PlayerID into it via Server call. Then within the Server event, check if the passed PlayerID matches the current PlayerController's PlayerID. If so, then perform you want to replicate, otherwise, do nothing.

Below is my example:

  1. Create a GetState (returns PlayerState) function inside your PlayerController. alt text

  2. Create GetPlayerID function inside your PlayerController. alt text

  3. Create IsCurrentPlayer function inside you PlayerController. alt text

  4. On your Server event, compare the passed object's PlayerID with the current PlayerID. If they match, then it means that the current player evaluating the event is the same as the one who called it via Server RPC call. Also, if you want to replicate it to other clients except the caller of the event, just use the False connector instead of the True one. alt text

Now that you know how to do it the hard way, here's the magic way of doing it:

  1. Pass the Client's PlayerController that called the event via ServerRPC. Inside the event, drag the connector from the passed PlayerController input and then use the IsLocalController or IsLocalPlayerController node. True means that the current player evaluating the event is the same as the one who called it via Server RPC call. alt text

more ▼

answered Jan 30 '19 at 01:04 PM

avatar image

Chyros
1.2k 8 4 8

avatar image rbx Jan 30 '19 at 03:02 PM

Wow it worked! Thanks!

(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