Announcement

Collapse
No announcement yet.

Typecasting

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

    Typecasting

    I tried a few different things but not sure if im going about this the right way.
    My player controller holds all of my important vars that i want to control my player except for the groundspeed(for obvious reasons, it resides in CustomPawn default properties)
    So if i wanted to display my groundspeed for debugging purposes through canvas...
    How would I typecast this Groundspeed var from my PAWN CLASS To my HUD class???
    if have tried:

    Code:
     if ( Pawn != none )
           SPawnJ = Pawn_J(Pawn); //like is done with (PlayerController) but errors happen
           SPawn.Groundspeed+=#.####
    this confuses me.
    Thanks for all help.

    #2
    *shameless bump*
    need help with this asap

    Comment


      #3
      You don't have direct access to a Pawn from a HUD unless your HUD extends from UTHUD. In that case the variable is called PawnOwner. If extending UTHUD is not an option for you, you'll need to go through the PlayerController to get the Pawn (variable PlayerOwner exists in all HUDs.

      You should also get an error for the last line, it should have been SPawnJ not SPawn. And just to be on the safe side you should check if the cast to Pawn_J doesn't fail in the if.

      Comment


        #4
        Also, if you're extending from UTHUD then it already has a hook for DrawHud() in Pawn so you can just go ahead and override the DrawHud() function in Pawn and draw GroundSpeed from there.

        Comment


          #5
          I understand you UnrealEverything, this was just some pseudo-code i slung up and not the actual code itself , although you did answer my question.
          What I was looking for was in fact PawnOwner.

          Comment


            #6
            Thank you evr, I was not aware that pawn had a DrawHUD() functionality.If I have any issues ill be sure to post back but I doubt that one of those two options wont work. Thank you guys so very much for the insight.

            Comment


              #7
              Originally posted by caster_0 View Post
              I tried a few different things but not sure if im going about this the right way.
              My player controller holds all of my important vars that i want to control my player except for the groundspeed(for obvious reasons, it resides in CustomPawn default properties)
              So if i wanted to display my groundspeed for debugging purposes through canvas...
              After starting the game use the console command "DisplayAll CustomPawn GroundSpeed" and it will show on the screen, you don't need to override a HUD class just for the sake of debugging.

              Comment


                #8
                It's all good. i needed to know how to do this anyhow. thanks.

                Comment

                Working...
                X