Announcement

Collapse
No announcement yet.

(Question) Respawning a player via it's transform only works if delay is used, why?

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

    (Question) Respawning a player via it's transform only works if delay is used, why?

    Hi, I've encountered something today and I would just want to know why.

    I'm using the "Respawning a Player in Blueprints" from the Docs.

    I'm trying to print the Actor-Test's transform in the GameMode, but why does it only show the correct values if a delay in GameMode is used?
    Here's my blueprints for GameMode and my Actor-Test (the Actor-Test is placed in the world at: x: 123, y: 123, z: 123):

    GameMode
    Click image for larger version

Name:	question_respawn_transform_gamemode.png
Views:	1
Size:	105.7 KB
ID:	1159774

    Actor-Test
    Click image for larger version

Name:	question_respawn_transform_actor.png
Views:	1
Size:	72.1 KB
ID:	1159775

    #2
    This is likely that your Event Begin Play is too fast for it's own good (game mode likely initializes before the objects in your scene have registered), I have had a couple of cases where I have to use minuscule delays like that as well because things simple happen too fast, I doubt there is any fix for this, but that is just my input.
    Marketplace Assets

    Advanced Mobile Input: Marketplace Page | Support Thread ――― Easy Input Remapping: Marketplace Page | Support Thread
    Multiplayer Blueprint Chat System: Marketplace Page | Support Thread ――― Closing Credits System: Marketplace Page | Support Thread
    Minesweeper Template: Marketplace Page | Support Thread ――― Maze Creator: Marketplace Page | Support Thread

    Comment


      #3
      Why not have the actor "Test" call an event on the game mode in place of Begin Play. That way Test (should) will always be ready before the game mode print string.

      Comment


        #4
        Originally posted by Jamendxman3 View Post
        This is likely that your Event Begin Play is too fast for it's own good (game mode likely initializes before the objects in your scene have registered), I have had a couple of cases where I have to use minuscule delays like that as well because things simple happen too fast, I doubt there is any fix for this, but that is just my input.
        That's what I thought, you are probably right.

        Originally posted by _cDub View Post
        Why not have the actor "Test" call an event on the game mode in place of Begin Play. That way Test (should) will always be ready before the game mode print string.
        I tested a few things, it seems I have to use a delay in GameMode if I want Actors to set values in GameMode (if I'm using the same variable in Event BeginPlay).

        Comment


          #5
          Yes, the BeginPlay of the GameMode is called earlier than the Actor's BeginPlay. With that Delay, the Actor gets a small timegap in which he is spawned and its BeginPlay can call.

          You will not want to use delays like that. There can always be a lag or something, which is longer than your Delay, and the BeginPlay is, AGAIN, too late.
          If you want to make sure that something is called at the time an Actor is available, you need to use its own BeginPlay.

          If you want to GameMode to do something when the Actor is ready, you will want to create a CustomEvent in the GameMode and call it from the BeginPlay of the Actor.

          Be sure that, in a Multiplayer Game, the GameMode is only available for the Server! Calling "GetGameMode" on the ClientSide, will result in a NULL reference.
          Open for contracted work | C++/BP (incl. Multiplayer) | Tutoring | VR

          My UE4 Blog/Page with Tutorials and more: Hit me for ALL the things!
          (Including 100+ Pages Multiplayer Network Compendium to get you started.)

          Comment


            #6
            Originally posted by eXi View Post
            Yes, the BeginPlay of the GameMode is called earlier than the Actor's BeginPlay. With that Delay, the Actor gets a small timegap in which he is spawned and its BeginPlay can call.

            You will not want to use delays like that. There can always be a lag or something, which is longer than your Delay, and the BeginPlay is, AGAIN, too late.
            If you want to make sure that something is called at the time an Actor is available, you need to use its own BeginPlay.

            If you want to GameMode to do something when the Actor is ready, you will want to create a CustomEvent in the GameMode and call it from the BeginPlay of the Actor.

            Be sure that, in a Multiplayer Game, the GameMode is only available for the Server! Calling "GetGameMode" on the ClientSide, will result in a NULL reference.
            I second this, don't use delays to work around bugs like this. But judging from DevSaucy's tone he wasn't planning to.
            Journeyman's Minimap - Available on Marketplace - Forum topic - Video

            Comment


              #7
              Originally posted by NisshokuZK View Post
              I second this, don't use delays to work around bugs like this. But judging from DevSaucy's tone he wasn't planning to.
              Correct. I'd rather not use delays.

              I found (as eXi said) CustomEvent in GameMode and call it from the BeginPlay of the Actor works how I want it to.

              I'm just doing a singleplayer game for now, multiplayer is far into the future haha.

              Thanks for the help everyone!

              Comment

              Working...
              X