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"

Get client's playerstate in gamestate in run on server event

I'm having issues with this. Anytime I try to get the client's playerstate like this it just gets the server's playerstate. Not sure how to fix.

FirstPersonCharacter Blueprint: Here

GameState Blueprint: Here

Product Version: UE 4.17
Tags:
more ▼

asked Apr 09 '18 at 09:13 PM in Blueprint Scripting

avatar image

SouthTTV
3 1 2 3

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

1 answer: sort voted first

Make sure you are running the piece of code which gets the Player Pawn inside the client.

You can simply check by printing IsServer before the AwardPointsTeam event or making a SwitchHasAuthority and executing through the Remote pin.

more ▼

answered Apr 09 '18 at 11:33 PM

avatar image

Gbr
44 5 13 15

avatar image SouthTTV Apr 09 '18 at 11:45 PM

I ran it through the remote pin of a switchhasauthority and all of the clients printed.

avatar image Gbr Apr 10 '18 at 12:13 AM

Hard to tell given only these pieces of code...

Change GetPlayerPawn to GetPlayerController, and your input as well, then get the PlayerState from it

avatar image SouthTTV Apr 10 '18 at 12:49 AM

GetPlayerController doesn't work either.

Here are some more pictures:

GameState: gamestate

FirstPersonCharacter: FPC

PlayerState: playerstate

avatar image Gbr Apr 10 '18 at 02:05 AM

Well, make sure that your GameState Ref really exists. Also, instead of passing PlayerController or Pawn by parameter, you can pass the PlayerState, considering you are inside the Character class, it stores a reference for it. Also, abuse of prints to make sure everything is on point.

After solving the problem, if the current solution works for you, I'd like to point out that replicating logic that needs priority to every client can cause conflicts and undesirable behaviours while synching movement, variable values, and can call events/methods improperly. Consider redesigning these blocks for the server to evaluate what is a Hit that counts and leaves the scoring to him. You can store the last hit information in a struct with lots of detailed data, for example, and gather these info to score the correct team (and lots of other game logics, too).

In a quick search I found this tutorial (https://www.youtube.com/watch?v=fwgCpHu7sD8) that might be useful for you to . You can move the Health logic to a RepNotify, then call the proper team score based on a Last Hit Data.

avatar image SouthTTV Apr 10 '18 at 11:04 AM

I decided to try casting to the playerstate after the branch in FirstPersonCharacter and passing it through AwardPointsTeam and it worked... So many hours I've spent on this problem so thank you man.

I will also change my logic like you said in the 2nd paragraph, thanks for the advice!

(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