Setting variables of a spawned actor in Unreal Engine
Published 29th January 2019 by Henry
As an example, say you want to spawn a blueprint actor called BP_FIRE_LOG and give it a unique ID number so that it can be referenced in the level.
The blueprint spawning the BP_FIRE_LOG blueprint is called BP_FIRE_SPAWN.
- In BP_FIRE_LOG, create a function called setLogID and add an integer input named logInstance with a default value of 0.
- Create variable logID in BP_FIRE_LOG
- Setup function nodes as below:
Now in the spawning blueprint Event Graph (BP_FIRE_SPAWN) create another integer variable called logInstance. The function setLogID can be called here, using logInstance as the input and an increment node straight after as shown here:
The logID/logInstance can now be used as an index, for example, in an array of instanced materials.
Leave a Reply