Playmaker Forum
PlayMaker Help & Tips => PlayMaker Help => Topic started by: Gibbagobba on April 01, 2018, 04:05:27 AM
-
I'm creating an FSM that can be applied to any prefab which sets its material to a colored wireframe based on its tag while storing the original material in a variable. When the wireframe button is pressed again, it sets the material back using this variable.
The main problem I'm facing however, is in applying this to nested objects. For example, I parent all my level geometry to an empty object for organization. This also means I can just apply my FSM to this empty object instead of every individual child. I can also set all of them to the wireframe material using this custom action: http://hutonggames.com/playmakerforum/index.php?topic=6429.msg31357#msg31357 (http://hutonggames.com/playmakerforum/index.php?topic=6429.msg31357#msg31357)
Unfortunately, this also means I can't store every object's material in a single variable and the FSM no longer knows what material(s) to restore and to which objects (making them all pink). How would I go about solving this problem?
-
Hi.
You might want to look into arrays.
Have 1 array for the objects and 1 array for the materials to "restore" to.
Then loop thru each index from the arrays
-
I used the Ecosystem action "Get All Recursive Children" to store the child objects in an array. Since one does not already exist that I can tell, I attempted to duplicate and modify the action to recursively get the materials of these children and store them in a second array. The FSM gets stuck on this action so I'm not sure what I should be doing.
-
Hi. After getting them into an array, you can loop thru the array using 'array get next', get the material and place in another array on the same index.
-
What command can store each child's material into an array index? None of them accept arrays as variables.
-
Hi.
Here is how you can do this :
(https://i.imgur.com/9Mdbwwjl.png)
(https://i.imgur.com/82RLSsMl.png)
(https://i.imgur.com/qYeKWh7l.png)