playMaker

Author Topic: Set property to multiple children.[SOLVED]  (Read 2049 times)

MAX_POWER

  • Playmaker Newbie
  • *
  • Posts: 40
Set property to multiple children.[SOLVED]
« on: November 13, 2016, 11:15:10 AM »
Hello. I have multiple characters with multiple skinned mesh renderer children and I need to access their cast shadows properties. I need to update those characters time to time so I can't access the skinned mesh renderers by draggin and setting the property for each one of them. Is there a way to change cast shadows properties from all children of an object? Basically I need a way to send to the parent object a command to change the cast shadows property of all children objects. Any way to do this? Thanks.
« Last Edit: November 15, 2016, 01:00:03 AM by jeanfabre »

elusiven

  • Full Member
  • ***
  • Posts: 233
  • Debt we all must pay...
Re: Set property to multiple children.
« Reply #1 on: November 14, 2016, 05:41:42 AM »
Send an event to each, to change it's properties? Or loop through all of them on an event and change the data to whatever you want. You can also send event with data.

So, you would find the main gameobject first,(Find GameObject) then find and count all of it's children objects. You can loop through them with Get Next Child action and count with Get Child Count. - You would do all of this on a global event, so all these actions would only fire on that event. And you would send that event from whenever you want that action to fire up

On the loop child state, you would get the component that you need (Get Component action), and set property of that component on each child, then finish that state, and loop it back to the loop state, once the loop goes through all childs it will go to finish state.

Also, a quick tip: just in case if you want to find a disabled gameobject, you can do so by finding it's parent first, and then finding it as a child of that parent. Otherwise if you find by gameobject, it won't work with disabled objects.
« Last Edit: November 14, 2016, 06:19:35 AM by elusiven »

MAX_POWER

  • Playmaker Newbie
  • *
  • Posts: 40
Re: Set property to multiple children.
« Reply #2 on: November 14, 2016, 12:36:26 PM »
Oh yes got it working just the way I wanted. Thank you so much for your help! Awesome