Announcement

Collapse
No announcement yet.

Cast on event begin play fails

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

    Cast on event begin play fails

    Is there any reason as to why an attempted cast when the game begins would fail, but succeed when a button is pressed?
    Even following a delay time after begin play, the cast fails.

    Any suggestions?


    Begin Play -> Delay [5] -> [Get Player Controller[0] -> Get Hud -> Cast to MyHUD] ==> Fail
    X key press -> [Get Player Controller[0] -> Get Hud -> Cast to MyHUD] ==> Success

    #2
    What kind off error do you get? A null reference ?
    VFX & AI
    http://www.team-imx.com

    Comment


      #3
      I'm not sure how to check which error it is, but more than likely it IS null.
      Any casting to hud through an event fails. The same cast succeeds from a key press.
      I am baffled...

      Comment


        #4
        Checking Get Hud -> isValid is producing a Not Valid result.

        When does get hud get invoked?

        Comment


          #5
          1. where is this graph in?
          2. BeginPlay was invoked at different time for different actors(ie world, gamemode, pawn, playercontroller, hud, etc...)
          3. always check if it's valid for things when you call getXXX, there is like double if not triple checking wall in the engine just to make sure things happen in a proper manner( you can imagine that with server/client model, many things could happen not in the order you like to believe.)

          I'm currently just scratch the surface of how the engine side in code works, so don't be too surprised that BeginPlay didn't help you to get everything when other stuff is initializing, as it only fire once.
          What you should do is to use events and function/interface to help you push/pull spawned actor info to/from the actor needed.
          Unreal Engine 4 Game Framework diagram for relation of all major base object types
          Unreal Engine 4 Input Event diagram, scroll down to section Input Processing Procedural
          Resident Evil Classic Camera
          RPCs official document, Must Read
          Everything you should know about replication

          Comment


            #6
            Have you used the blueprint debugger? Play the game, open the blueprint, and see where the cast event fails. There's also a node where you can specify an event when a cast fails to call another action/event/node.

            Comment

            Working...
            X