UE1 - UT Getting properties of a class stored in a variable

  • Two Factor Authentication is now available on BeyondUnreal Forums. To configure it, visit your Profile and look for the "Two Step Verification" option on the left side. We can send codes via email (may be slower) or you can set up any TOTP Authenticator app on your phone (Authy, Google Authenticator, etc) to deliver codes. It is highly recommended that you configure this to keep your account safe.

Rajada

Member
Jan 21, 2008
213
0
16
rajada.tumblr.com
The setup is like this:

There's a standard variable in PlayerPawn like this:

var class<HUD> HUDType;

I want to get a property (using code within a custom PlayerPawn class) from that PlayerPawn's HUDType, but the variable I want only exists in a custom class that extends HUD. What I essentially wanted to do was:

SomeVariable = SpecialHUD(HUD).SpecialProperty;

Understandably though, the cast wouldn't work there (cast from class to SpecialHUD will always fail). I've tried using DynamicLoadObject, and while it did compile, it doesn't actually work. I tried something like:

SomeVariable = SpecialHUD(DynamicLoadObject(string(HUDType), class'class')).SpecialProperty;

Is what I am trying to do even possible on this engine?
 

gopostal

Active Member
Jan 19, 2006
848
47
28
Depends on the variable. Is this something local on the client that doesn't go to the server? If so you won't be able to share that unless proper replication is set up.

Sorry I dropped away last year J. I was having some serious issues dealing with my health stuff. I think it's pretty stable now (I had to get all my teeth removed and some other stuff done) and I've been working on finishing FoodFight for the UT99.org guys. If you want to email me I wouldn't mind picking back up and helping you out with your stuff.
 

gopostal

Active Member
Jan 19, 2006
848
47
28
If it's calling out from one package to another then you'll need to set up replication. You can extend HUD and you can even force that new HUD on clients but it's internal values won't be shared unless there is declared replication for it.

Say I add a HUD so that the person that the player hurt last has their name displayed on the HUD. I'd do this by assigning the person who was hurt's name to a string value that's displayed by the HUD on the client. I'll call that value "LastHurtPerson". In the HUD I'll make it display the value of LastHurtPerson off to the side of the player's HUD. This will all work just fine BUT if the server want's to see what the value of that string is on an individual player it will be unable to do so since it's a local variable. In order to share this value I'd have to declare replication for it in the HUD class.

I can post some examples to you if that might help? It can all get confusing I know.
 

Rajada

Member
Jan 21, 2008
213
0
16
rajada.tumblr.com
Typecasting for class values ("metacasting") uses exactly the same syntax as variable declaration for the type part. Additionally, you have to tell the engine to access the default value of that property:
Code:
someVariable = class<SpecialHUD>(HUDType).default.SpecialProperty;

I should have mentioned I was already trying to get the default property, but I just didn't know how to do the metacasting. Thanks for that. It works fine now.