Updating array of struct

The script if fine, I am not 100% sure I understand the issue, though; but hear me out:

The Construction Script runs :

  • when actor is spawned; that exposed variable will be updated with no additional script:

image

  • when an actor is placed and / or dragged in the scene
  • when a Child Actor Component instantiates an actor
  • when actors’ data gets updated - this can be done by flagging variable as Instance Editable:

If you do the above, the actor fill fetch data from this variable, no matter what you set its value in BPs.


Since this is what I believe you’re after, in your case:

image

As soon as you hit enter, every index of this array will have 2 assigned.


  • sometimes you do not want to run the entire CS or need to run something unrelated to the CS, you can use Editor Callable Custom Events:

Here I assign a value to an array inside the actor. This has nothing to do with CS, but simply updates the instance of the actor.

  • there are also EUWs - Editor Utility Widgets. They can do the above but the script does not belong to the actor. Let’s say you want to select 14 / 20 actors in the scene and update their arrays all at once to some specific values. Or make them trace their surrounding. The script does not need to clutter the affected actor and can live in a specialised widget that can be only run outside of PIE.

  • the Construction Script does not run for actors placed in the scene when the game starts

1 Like