playMaker

Author Topic: How to find an object that may be child of two different parents?  (Read 1378 times)

Silicon Power

  • Full Member
  • ***
  • Posts: 186
Hey guys, I need to get a child but there is two parents I don't know which parent the child is attach on that moment! I don't want to use find object because hierarchy is heavy this can effect performance. Also I can't check if a parent contains that child before this action. Is there a way to do this on same state?

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7618
    • jinxtergames
Re: How to find an object that may be child of two different parents?
« Reply #1 on: August 08, 2023, 06:31:04 PM »
Hi,
Maybe you can have a GameObject variable on the root and set the object that you want to look for into that variable?
you can use a Template with a Run Fsm if you have to do something in the same state that needs more that 1 state.

Silicon Power

  • Full Member
  • ***
  • Posts: 186
Re: How to find an object that may be child of two different parents?
« Reply #2 on: August 16, 2023, 01:38:15 AM »
Hi,
Maybe you can have a GameObject variable on the root and set the object that you want to look for into that variable?
you can use a Template with a Run Fsm if you have to do something in the same state that needs more that 1 state.

The problem is with Get Child action! It removes previous value and set value to none if can't find child on second parent. why it should be like this? If can't find child it could still keep previous value.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7618
    • jinxtergames
Re: How to find an object that may be child of two different parents?
« Reply #3 on: August 17, 2023, 07:05:32 AM »
Hi.
This is normal C# behavior.
What you can do is have a 2nd variable (last selected child) then use get child, then use Game Object Is Null to check if it found something.