playMaker

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

Doh

  • Playmaker Newbie
  • *
  • Posts: 27
    • View Profile
Finding a child during runtime
« on: April 20, 2017, 08: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

  • Playmaker Newbie
  • *
  • Posts: 27
    • View Profile
Re: Finding a child during runtime
« Reply #1 on: April 20, 2017, 08: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: 100
    • View Profile
Re: Finding a child during runtime
« Reply #2 on: April 20, 2017, 01: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

  • Playmaker Newbie
  • *
  • Posts: 27
    • View Profile
Re: Finding a child during runtime
« Reply #3 on: April 20, 2017, 02: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: 1835
    • View Profile
Re: Finding a child during runtime
« Reply #4 on: April 21, 2017, 12: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.