playMaker

Author Topic: Finding a child during runtime  (Read 1603 times)

Doh

  • Full Member
  • ***
  • Posts: 124
Finding a child during runtime
« on: April 20, 2017, 11:47:08 AM »
Hey, I'm finding it difficult to find a solution to this.

I have a game object that takes on different child objects during runtime, though only ever one at a time. My issue is getting an FSM to check for the child object once it takes on the new parent.

So far I've only been able to get it to check for a child on start, this results in a negative response obviously as the child is not there yet.

Any pointers would be greatly appreciated!

Doh

  • Full Member
  • ***
  • Posts: 124
Re: Finding a child during runtime
« Reply #1 on: April 20, 2017, 11:56:32 AM »
I've only just discovered global events... oops. I think this may be where I need to look.

MajorIdea

  • Full Member
  • ***
  • Posts: 131
Re: Finding a child during runtime
« Reply #2 on: April 20, 2017, 04:40:45 PM »
Not sure if I'm understanding the issue but you could perhaps use the Game Object Is Child Of or Get Child Count and update when that number changes.

Doh

  • Full Member
  • ***
  • Posts: 124
Re: Finding a child during runtime
« Reply #3 on: April 20, 2017, 05:44:58 PM »
I managed it using "get child num" and keep it checking by applying a one second wait which then loops back and starts that state again.

Is there a way to listen for the change rather than checking?

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Finding a child during runtime
« Reply #4 on: April 21, 2017, 03:16:38 AM »
Hi,
Maybe you can use an array to place your objects it and find them there,
that is better for performance.

if you are creating the child object you can store the object in a variable and then add to an array.