dynamic cast.

I see a lof of cast functions which although work well can be problematic uf trying to cast in a loop and to different types. id there a cast function with which you can take in a variable and a data type and it outputs the variable cast to the specified datatype?

I believe casts are class specific. Here’s an example I ran into recently:

Get game mode -> Cast to GameMode_Mod

When my mod was loaded first, the cast was successful. However, when I put my mod second, the cast failed as my modded game mode was no longer the default game mode for that session. You’ll also notice that typing “Cast To” will return every specific class, unfortunately no master class types.

Yes I noticed that and it lacks flexbility. What I am after us a nore dynamic cast system, for example

say input Mymode is of object type, input b is GameMode_Mod, so output would be a version of mymode casted to GameMode_mod for example.

If what you’re referring to is involving hierarchy, then casting to the parent is applicable to any child. I.e If the class you’re casting from is a child of the class you’re casting to is a child, regardless of a specific variable type or being of type object it will be successful - if the reference is valid.

You just cannot access anything from a child if it is unique to said child.

-WM

Good point. I’m not sure of the properties of the parent class though.

Rather than beating around the bush and being vague, what is it you’re trying to accomplish with said casts, exactly?

-WM

It’s ok, I solved it. Casting to the base class maintained the properties I required.