No announcement yet.

Player input and events to server

  • Filter
  • Time
  • Show
Clear All
new posts

    Player input and events to server

    Here's my situation:

    I have a pre-defined area where I want a player to be able to do an action. However, this action needs to come from a menu on the player's screen. Essentially, the sequence would look like this:

    1. Player moves into area
    2. Player presses a button to bring up a UMG menu on their screen
    3. Player clicks a button on the UMG screen
    4. Action triggers(for example a light turns on)

    I have the individual parts generally working, but I'm not sure how to do the replication properly between the server and the clients. I think what I need to do is this:

    1. OnComponentBeginOverlap is called on the server
    2. The player controller that caused the overlap event has a variable set, which will allow the client to pop up a UMG menu on their screen.

    Is this the right way to do it? If so, how do I get the player controller of the actor that caused the overlap event?

    I figured out part of the problem. In order to get the player controller from the actor that OnComponentBeginOverlap gives you, you must cast it to a Pawn object(e.g. default_soldier for some of Epic's sample projects), and then use the 'Get Controller' method on that pawn in order to get the player controller.

    Now that I have the UMG screen popping up on command, I need to call a method on the server. I have a reliable replicated function on the server which I was able to call before in the OnComponentBeginOverlap. I have tried calling the replicated function from the OnClick event of a UMG button, but it never replicates to the server. Any ideas?