Announcement

Collapse
No announcement yet.

Getting variables from unspawned actor component

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

    Getting variables from unspawned actor component

    This is our problem:

    TestComponent has a set of variables we would like to access from other blueprints.

    TestSubclassA has a 'TestComponent with the set of variables modified'
    TestSubclassB has a 'TestComponent with the set of variables modified'
    ...
    TestSubclassZ has a 'TestComponent with the set of variables modified'


    We would like to create a function which says "Given this class, return the values of the variables contained in TestComponent" - taking a class reference variable as input.

    The TestSubclasses are unspawned when this function needs to be called, so using interfaces, construction scripts, functions called by BeginPlay etc are not an option.

    Spawning an instance of the class to pull variables from its component before deleting it is not an option as this would affect many other functions in the game.

    Each TestSubclass has majorly different functionality so having all inherit from the same base class is not an option.

    Can anyone help with a solution?
    Last edited by mbelarouci; 07-21-2016, 12:08 PM.
    My current question - Getting variables from unspawned actorcomponent

    Our game - Robots Minerals Profit! - a side-on builder game with cooperative multiplayer, made in UE4.

    #2
    You have a bunch of options from C++ such as this:

    Code:
    auto Default = GetDefaultMutable<UTestComponent>();
    From Blueprints I don't know; maybe you need a custom Blueprint node to do that...
    Try the "Construct Object from Class" node to get class default values.
    Last edited by BrUnO XaVIeR; 07-21-2016, 12:23 PM.
    | Savior | USQLite | FSM | Object Pool | Sound Occlusion | Property Transfer | Magic Nodes | MORE |

    Comment


      #3
      Thanks for the suggestion! Is there any documentation for this anywhere?

      E: is this function in the UE4 4.12.5 engine code? Cannot find any mention of it and it returns undeclared identifier.
      Last edited by mbelarouci; 07-21-2016, 12:58 PM.
      My current question - Getting variables from unspawned actorcomponent

      Our game - Robots Minerals Profit! - a side-on builder game with cooperative multiplayer, made in UE4.

      Comment


        #4
        Using a custom blueprint node is very simple to do this.
        You just get an TAssetPtr and if the asset is valid you call .Get() function to return the default object from that asset/blueprint class.
        But C++ required... Every class has an unspawned default object, Blueprints seem to not have access to get defaults.
        Maybe Rama's custom blueprint library has a node for that already, I don't know.
        | Savior | USQLite | FSM | Object Pool | Sound Occlusion | Property Transfer | Magic Nodes | MORE |

        Comment

        Working...
        X