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"

AnswerHub Maintenance

Background maintenance is scheduled to occur between 9 - 11am EDT on Tuesday, May 21. Site operation may be slower than normal during this time and a brief interruption in operation may be observed

The server is never locally controlled?

Hi guys,

I'm working on a multiplyer game for the VR Vive, so I followed tips from this site: http://heliosinteractive.com/project-artemis-ue4-multiplayer-vr. But one part is failing. alt text

When the server (which is also a client) check the "IsLocallyControlled" node, he never returns true. So he never send his position to the other clients but can see them moving around. I figured this out threw severous logs and print string. Is it normal? Am I missing something? Thanks for the answers guys. Cheers.

Product Version: UE 4.12
Tags:
blueprint.png (110.6 kB)
more ▼

asked Aug 03 '16 at 03:45 PM in Blueprint Scripting

avatar image

Maynlie
21 2 4 7

avatar image Tobiw Mar 16 '17 at 06:27 PM

did you maybe figure this one out? I have the same problem:

 if (World)
 {
     if (IsLocallyControlled()) {
         GEngine->AddOnScreenDebugMessage(-1, 7, FColor::Blue, TEXT("spawn light success"));
         NoctovisorLight = World->SpawnActor<AAlienLightHolder>(AAlienLightHolder::StaticClass(), GetActorLocation(), GetActorRotation());
     }
 }

executes on owning clients but not if the server is the owner

avatar image ExtraLifeMatt Mar 16 '17 at 07:49 PM

You probably want

 if ( HasAuthority() || IsLocallyControlled() )
avatar image Tobiw Mar 16 '17 at 07:53 PM

no, in the case of a client calling this, the spawning would execute on both the client and the server since both of them pass the if statement

avatar image ExtraLifeMatt Mar 16 '17 at 09:15 PM

Ah, right. My mistake, what you want to check for is the NetMode and see if it's the listen server as only the listen server can have a local client in addition to being the server.

 if (GetNetMode() == ENetMode::NM_ListenServer || IsLocallyControlled() )
 
avatar image Tobiw Mar 18 '17 at 03:06 PM

Unfortunately this produces the same effect as your previous proposition. I want the code to execute only on the calling controller. With this, if the client calls, the server AND the client execute it.

(comments are locked)
10|2000 characters needed characters left

1 answer: sort voted first

Ok so after hours of fighting i figured it out. You just can't call this function on beginPlay, apparently the server needs some time to connect the player controllers, so just do it after a delay

more ▼

answered Mar 22 '17 at 08:39 PM

avatar image

Tobiw
143 6 9

(comments are locked)
10|2000 characters needed characters left
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