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"

Correct usage of "Is locally controlled" in Character? [4.8.3, Blueprints]

I want to initialize my Pawn/Character. Some things for the locally controlled Character, like creating a HUD. On the other hand some things for all but the locally controlled, like setting their mesh's material to enemy or friendly colors and creating a healthbar over their heads.

At first I tried setting up everything in Event BeginPlay, but that was problematic since "Is locally Controlled" did not work as expected. (Always returning false, for details just search here for "locally controlled")

I worked around it with a Delay, but Delays might (and did) not work everytime and I like to do it the correct way. I read about the problem and found out some ppl have the same problem. And I seen many "dirty" solutions like the Delay and some which sounded cleaner.

What I tried:

  • I tried to work on "Event Possessed", but this is only Serverside, I need to do have it executing on the server and on every client.

  • I tried to reliably multicast the "Event Possessed" to all clients, but this would again only work if I inserted a Delay. With no delay it would only reach the server.

  • I tried to work on "Event OnPostLogin" from within the GameMode, "Get Controlled Pawn" from new player, casting to my character, then sending a reliable multicast custom event. But this only landed on the server. A Delay right before the multicast brought it to work, but again "Delay". [1] [2]

  • I tried to use a "DoOnce" in "Event Tick" on the Character, but sometimes it did not work either, local Player did not know that he was the local player.

This is not really a good situation. I think every new developer will stumble upon this non-obvious behavior when using "Is locally controlled".

  • I would like to have a "Everything is set up, Begin Play", now comes my logic and the engine has set all it needed to set.

  • I would like my Character to Tick on the Controlling Client only since he knows that he is in control.

  • Alternatively having a "OnPostLogin" in GameMode that can multicast to all the clients.

  • Alternatively having a "Event Possessed" in Character that can multicast to all the clients.

Essentially the current state means; I can't make descisions in BeginPlay and I need to break out of Tick as long as Im not sure if everything is set up.

Sidenote: using a "Run on owning Client" instead of a Multicast from "Event Possessed" worked, but it did not solve my setup needs for all the non-local clients (creating healthbar, setting colors) since the message is not transmitted to them. This even fixed "Event Tick"s behavior of not knowing if it is locally controlled AFAICT.

UPDATE to Sidenote: AND it fixes "BeginPlay", the local client knows who he is, if there is a "Run on owning Client" executed before, even if it does nothing... strange.

[1] Ryan Gerleve: https://answers.unrealengine.com/questions/126944/is-locally-controlled-returns-true-for-remote-play.html

[2] Ben Halliday: https://answers.unrealengine.com/questions/212604/is-locally-controlled-function-returns-false-on-cl.html

Product Version: UE 4.8
Tags:
more ▼

asked Aug 24 '15 at 04:00 PM in Blueprint Scripting

avatar image

JanSordid
191 4 11 23

(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