Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: ttham on February 03, 2017, 11:10:05 PM

Title: Applying color to all light in array at ones.
Post by: ttham on February 03, 2017, 11:10:05 PM
Hi.I have array of lights I need to apply one color to all of them with "Color interpolate"  but if i'm using "Array get next" action, its working one by one,how to do it simultaneously? Tank you!
Title: Re: Applying color to all light in array at ones.
Post by: ttham on February 04, 2017, 08:49:25 AM
I guess i need something like "foreach" but i can't find any action like that.
Title: Re: Applying color to all light in array at ones.
Post by: Dreatern on February 04, 2017, 02:19:07 PM
What about use a FSM template with everything you need and use the template on each light.
That way i believe you can change the "main" template and every light will react to that at the same time.  I think templates are instances but I do not know the behavior at runtime


Title: Re: Applying color to all light in array at ones.
Post by: ttham on February 04, 2017, 07:12:50 PM
Yea i saw that action, but a was afraid that this is gonna be bad for performance.
But if there is no other way i have no choiсe. Thank you.
Title: Re: Applying color to all light in array at ones.
Post by: elusiven on February 05, 2017, 10:08:03 AM
You can use the array get next to perform actions for each object in array. Templates can work like methods. You can pass data to it and perform actions involving that data and then return events with data. So you can pass a light game object to a template then perform actions on it and then send event or just finish fsm.
Title: Re: Applying color to all light in array at ones.
Post by: ttham on February 05, 2017, 08:54:32 PM
Ok I'm trying this http://prntscr.com/e50atk (http://prntscr.com/e50atk)
This what i have on a light object.http://prntscr.com/e50b31 (http://prntscr.com/e50b31)
"Light" is global variable.and it's not working.
If i set it on self its just change color on game start.
I can use global transition of variables to activate template, but it will affect all lights in scene not only those that i picked in current array.

Title: Re: Applying color to all light in array at ones.
Post by: ttham on February 07, 2017, 12:30:10 AM
Ok its working now, but it still goes one by one. Even with that for each action.
Title: Re: Applying color to all light in array at ones.
Post by: jeanfabre on February 07, 2017, 12:52:21 AM
Hi,

 Don't worry with iterations and loop in this sort of features, it's fine. Be aware that even if a custom action was made, it would still need to iterate trhough that list anyway, so actually makes no difference, the slight overhead of doing it manually is totally insignificant compared to what could go wrong with shaders, visual effects, meshs in your scene that would affect frame rate and performances way more.

 Bye,

 Jean