Announcement

Collapse
No announcement yet.

get player character issue 4.20 bug or glitch?

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

    get player character issue 4.20 bug or glitch?

    Hi,
    So I've spent a good few hours working on an issue I had with making a smoke bomb. It worked and then the next day it didnt.
    It turned out that on begin play my get player character wasnt working. Then while spawning the smoke bomb from player character I set it as the owner and instigator but the methods to get those also didnt work. All three resulted in player being set as none. Finally I used expose on spawn and set it like that which finally worked. I think this might even be a better way of doing this however I still want to know what happened as Ive used this method throughout my game, why it suddenly didnt work. Did I change a setting or something. Maybe press a hotkey. Does anyone know. Thanks

    #2
    Tenchi-Official

    This sounds like one of the many race conditions / timing issues you see in Unreal... Just wait till you package things up or during multiplayer testing etc... ... What's happening... While Blueprint isn't multi-threaded per se, the underlying C++ is, so things often run in a different order than expected each time. For example how do you spawn your Player-Pawn right now... Semi-automatically in Maps & Modes Project-Settings, or manually in Gamemode... The code for spawning may not complete before 'the code after it does'. If so, you risk running into conflicts...

    What can be done about it..... You need to be aware of the different dependencies in your code and be careful about the assumptions you make. In short, developers often strategically sprinkle-in a few Delay nodes here and there. But a better practice as you've discovered in exposing variables on spawn, having polling loops (IsValid BP-circuit loopbacks on a delay), and during development logging events to the screen (print-strings of game time / step executing etc), so that you can see where the execution problems arise out of order. Plus, follow threads like this...
    Last edited by EntrpriseCustomr; 09-15-2018, 03:46 PM.

    Comment


      #3
      franktech Thanks alot for the info. This is interesting. I believe I used a setting where i can select my player bp and default hud and such I think that was game mode. I would have thought there is no way for the code to run in the wrong order as the logic to spawn the smoke bomb is in the player itself and done with input actions(if its still possible that things are running out of order surely by the time I use a second or tenth smoke bomb player character must have been set as the begin play should run in each instance ).

      I dont like the idea of using delay nodes, i have some but dont want to rely on them so im probably going to use spawn variables. However, from what you tell me I gather that potentially everywhere (there are a lot of places) i used get player is susceptible to breaking and that means I need to check each one ( might have nightmares about this tonight ).

      I checked that link out so thanks for that too as its gonna save me some headches but the weirdest issue is that it was still in editor while working and when it broke which is what has me confused. Do you have anyother links about the dependencies i might have

      Comment


        #4
        This is another approach which you can try in places where the code is critical and just can't FAIL.

        I like to use delays to get code up and running quickly and avoid decision paralysis. But then strip them out and see where the problems arise. Often just adding a Branch with an IsValid = None check (or print-string and F9-Breakpoint) can quickly draw you to problems (output / message log is also mandatory).

        Remember to use BP comments everywhere too and add your own 'searchable' Tags inside comments as warnings, or as a Todo / Reminder to go back and evaluate code later on (if some assumptions turn out to be unsound etc). Here's 2 other bookmarks, but the advice from TheJamsh is worth more than the chart imho...

        Link1

        Link2

        Comment


          #5
          franktech Thanks again. I had no idea you could make searchable tags in comments. I've grown so confident with Unreal but theres still things that I have to learn. Recently I saw a 3 year old AI livestream from mieszko and wow it helped so much. (i think we should have links to livestreams directly on the docs of those topics for anyone from epic on here)
          Ill try the delays.

          Comment


            #6
            Yep some of those older livestreams are pretty interesting.... What was the link to the AI one?

            Comment


              #7
              franktech The 3 year old one is here https://www.youtube.com/watch?v=NZZtMNdJk5o
              just found a new one i havent seen https://www.youtube.com/watch?v=nshHCycft4A

              Comment

              Working...
              X