![]() |
![]() |
|
#1
|
|||
|
|||
|
I created a new class, CustHud, extending ROHud with the single function of overriding DrawVehicleIcon to remove the throttle and dials from the HUD display. I am trying to call the overridden DrawVehicleIcon in the following manner, which is from the DrawHud function. I have the DrawHUD in a new class extending from ROTankCannonPawn.
My code: if (CustHud(PC.myHUD) != none && ROVehicle(GetVehicleBase()) != none) CustHud(PC.myHUD).DrawVehicleIcon(Canvas, ROVehicle(GetVehicleBase()), self); The original code looks like this: if (ROHud(PC.myHUD) != none && ROVehicle(GetVehicleBase()) != none) ROHud(PC.myHUD).DrawVehicleIcon(Canvas, ROVehicle(GetVehicleBase()), self); In looking at the log messages I put in and it is appears not be typecasting properly with CustHud because it doesn't get by the "CustHud(PC.myHUD) != none" check. It is returning none, thus fails the if/then. But, if I change CustHud to ROHud it works (no surprise there, right). Looked over the Unreal wiki and I've tried a couple different ways to typecast with no success. Any thoughts or suggestions. Am I doing this the right way? Is this a typecasting problem? Thanks for any help! |
|
#2
|
||||
|
||||
|
Im pretty tired, so forgive me if im totally off atm.
Wouldnt your PC have to have the HUD defined as a CustHUD for that check? Of course you subclass from ROHUD but your PCs HUD is a ROHUD and not CustHUD. I think a typecast there will always result in a none. Why do you need to cast it anyway at that point? The variables and functions you are referencing are in the ROHUD anyway. |
|
#3
|
|||
|
|||
|
You're on the mark. I tried a few more things and you are correct. The PC uses the ROHud, so trying to use an extended class of ROHud does return nothing. Had a feeling this was the problem but thought it may allow the typecasting because the CustHUD is extended of ROHud. This has been a definite learning experience.
I was trying to cast it to create a HUD without the dials, throttle, and change the text for the "Driver". I wanted to override DrawVehicleIcon in ROHud. I can use the optional variable DrawVehicleIcon to prevent the dials and throttle from being drawn, but the driver name is using the default value in ROVehicleWeaponPawn for DriverHudName. Thanks. There is another option or two I can try. |
![]() |
| Thread Tools | |
| Display Modes | |
|
|