Best practice for using object variables, in children from root, every frame
--------------------------------------------- Would using an actor to get a variable in a specific child object like this for example: imgur.com/7XGIJFS and using it like this: imgur.com/LxuCFom
surely using the actor for initializing the gameobject would be better performance than just using it like this every frame?: imgur.com/4itHpKw
How about just simply using "Scope" and assigning that to something like "From Root" every check? Although this sounds the most costly as it must search every object to find the variable
Or assigning the actor to a global object and checking or changing the variable using the global object.
Object ID is probably the best answer if any object running the schematic is using that one Object ID, but in the case of multiple objects using their own object ID (for example getting the schematics weapon hand's object variables) one of the methods above is needed. ---------------------------------------------
I am having trouble testing the cost of each of these methods out to find the best way performance wise, I have tried a variable set to time before and after the check variable node, displaying the variable in console and using profiler but no luck.
Does anyone have any tips or ways to optimize the nodes in your schematics?
Profiler and Deep Profile
Granted I do not have a lot of experience with using the profiler, but if you have a simple single schematic running with 1 node which you want testing, you can see by going down the profilers Overview hierarchy beginning with MakinomHandler.Update() and halfway down MachineHandler.Tick(), which nodes take up what amount of time. The problem is that this isn't a consistent time or % amount even though nothing has changed, so this way at the moment I think is useless.
If anyone uses the profiler specifically Deep Profile with Makinom despite not being able to see a lot of information (yet) please share how you use it, or any script directions to use with it.
Naturally, the less often you do something, the better it's for performance - but if it only happens for a few objects per frame, it doesn't really matter. If it's something that is used for hundreds or thousands of game objects per frame, that's another case.
Generally, Makinom relies on Unity's built-in functionality for getting child objects or components of a game object, which is already very optimized.
If you want to test the different methods to check which is the best for performance, you'll need to have many objects run the schematic to be able to see the differences in the profiler. When I did performance optimizations for Makinom a few months back, I had thousands of game objects run schematics to see the difference between various implementations.
Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found. If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
Hmm so if it is using Unity's built-in functionality, is a node searching/getting for the child object every frame if I have a repeat schematic node afterwards?
If that's the case say I have lots of nodes in lots of schematics doing this every frame on repeat since the start of the game, would it be better to initialize the object and find the child using found objects or assigning it to an actor once when the schematic (game) starts, then telling the repeating node to use the actor or found object?
It's probably better - you'll need to test it to see if it really makes a difference. Might be that getting the child object each frame is just as performant as getting the stored game object.
Post edited by gamingislove on
Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found. If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
Generally, Makinom relies on Unity's built-in functionality for getting child objects or components of a game object, which is already very optimized.
If you want to test the different methods to check which is the best for performance, you'll need to have many objects run the schematic to be able to see the differences in the profiler. When I did performance optimizations for Makinom a few months back, I had thousands of game objects run schematics to see the difference between various implementations.
If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
If that's the case say I have lots of nodes in lots of schematics doing this every frame on repeat since the start of the game, would it be better to initialize the object and find the child using found objects or assigning it to an actor once when the schematic (game) starts, then telling the repeating node to use the actor or found object?
If you're enjoying my products, updates and support, please consider supporting me on patreon.com!