Hi, is there a way to run code whenever actor properties are being changed/updated? Like position, on destroy/end play, or any custom variables etc.?
Thanks.
Hi, Are you meaning in the actual actor itself or in the editor?
If the Actor, yes you can do that from the ConstructionScript:
If in the Editor, there are hooks you can add handlers to for such things in C++, e.g.:
LevelEditorModule.OnActorSelectionChanged().AddRaw(this,&FrdBPTools::OnActorSelectionChanged);
There may be ways to do this from Editor Utility Blueprint as well, but I haven’t looked.
I mean the actor, but with Construction Script, I saw that it doesn’t run when actor changes position (transform).
Do you mean during play?
There is no event that I know of, a common technique is to create a Transform variable and check it in the Actors Tick - when different from GetActorTransform() it’s changed, do your processing and set it to the new Transform.
Just in case anyone reading is not getting the construction script called when dragging in the editor, there is an option in class settings to enable it.
Yeah, I mean at runtime. Tick doesn’t cut it if you have thousands of actors, so I guess there’s nothing.
I agree - when it comes to 1000’s of actors it may be time to either make them ISMs and control them from a singleton or use ISMs and switch to Actors when close by.
That gives benefits in other areas too.