Announcement

Collapse
No announcement yet.

How to Get variables values from 2 different players?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    How to Get variables values from 2 different players?

    kay hello, peoples everyone. I've been trying to find an answer for this for a while now , is that all i want to do is Spawn an object Using a specific XYZ variable that which value is set by another player .

    This would be important, If Player 2 wanted to set a waypoint location for player 1. But as I see it There is no want to get that variable from Player 1, to player 2... How could This be done?
    It's kind of simple but so important, and I have no Idea how this could be done.

    Any help, or pointing in a direction on where to look would be very much appreciated. thx

    #2
    Hey there,

    I would create a publicly visible variable in a custom GameInstance, GameState, or even GameMode blueprint (better to use one of the other two though), this way both players can access it easily. Make sure to assign the new blueprint as your default GameInstance/GameState in your GameMode blueprint, and create a new vector variable named location (or whatever you want ) and set it as "Visible".

    With a public variable exposed in one of those blueprints, you can then set the values like this from your character blueprint:
    Click image for larger version

Name:	GameState.PNG
Views:	1
Size:	90.6 KB
ID:	1062175

    So long as you cast to the type of blueprint you made, you will be able to access it's public (visible) variables from any other blueprint in your level. Hope that helps!
    Last edited by DotCam; 12-15-2014, 04:59 PM.
    Free Community Ocean & Sky Project || Join us on Discord! || Trello Roadmap

    Comment


      #3
      I would consider a struct or array of structs. Build the struct and add a team Id to it. Send the WP struct to the server via function (Replicated From Client: Executes on Server) and within that function call and send the struct to another function (Replicated: Multicast) back to all clients. Let the clients decide on the team ID if they render the WP or not.

      Edit: maybe: Replicate From Client: Executes on Server -> Loop over Player Controller -> match Team or Player Id -> call Replicated Function: Run on owning Client? Not tested yet (something was not quite ok with that one, but I can't recall that right now)
      Last edited by Wolfsblut; 12-15-2014, 05:29 PM.

      Comment


        #4
        Thank you soo much You made my friggin week sir. I can finally work on this multiplayer idea ARHGHH SO Happy

        Comment


          #5
          Hey, I'l look into Structures, and try to do what your saying, but how would i assign, A Team ID? Is this possible with blueprints?

          How exactly would you, make a player match something like a team ID?

          Comment


            #6
            You have to tag the player and teams by yourself.

            Comment

            Working...
            X