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"

Why my character can't execute a RPC On Server?

Basically, I have a GameMode which has the MainPlayerController as the PlayerControllerClass, as follows:

alt text

As you can see, there's no Default Pawn Class because the MainPlayerController is the one responsible for spawning the character into the world. And this is how I do it:

alt text

Though the BP seems confusing, what it does is pretty simple: On BeginPlay, the Server spawns the character in a random location.

One important thing to note here is that I'm passing the MainPlayerController as the owner of the character. This is because I've read a lot about ownership and replication and seems only characters owned by clients (which are, per say, controllers) can run an RPC Run On Server.

My Character, which is Character_Main, has a function called Add Item To Inventory. This function basically executes when the player clicks on an item which is in range with the character.

Also, this Add Item To Inventory function is the one responsible to call an Event that'll only occur in the server. Contextually speaking, the server has to destroy the item from the "real world" and afterward transmit this information to all the other connected clients.

My misfortune here is that this event that only should be run on the server is not being called. This is how Add Item To Inventory is implemented:

alt text

Currently, I'm debugging the game running the server as a dedicated one instead of p2p. But if I unmark the option Run as a dedicated server, the server character is able to run this event seamlessly.

THINGS TO KEEP IN MIND:

  • I've tried to put a Print String with the Display Name of the owner of the character and it displays the expected value, which is MainPlayerController.

  • The owner of my character is MainPlayerController, but it is possessed by an AIController. This is a TopDown game and I found no option if not doing this because of the movement replication (ideas are welcomed).

So, my final question is: what am I doing wrong?

Thanks!

Product Version: UE 4.18
Tags:
more ▼

asked Feb 06 '18 at 06:08 PM in Using UE4

avatar image

chiefGui
53 3 11 14

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

0 answers: sort voted first
Be the first one to answer this question
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