0
Answered

How to get control of child game objects from nonEmbeded flow machine?

Дмитрий К 2 years ago updated by Eduard_de_Bruyn 10 months ago 4

I have a parent game object with macro flow machine which has custom event listener inside. I also have a child game object, which i want to set active by trigger from the parent object. How do i do that without making tags, instantiating, getting and setting variables? Is there a simple way?

Bolt Version:
1.4.0F9
Unity Version:
2018.2.15f1
Platform(s):
Scripting Backend:
.NET Version (API Compatibility Level):
GOOD, I'M SATISFIED
Satisfaction mark by Дмитрий К 2 years ago
+1
Answered

Hi! 

If I understand correctly, you want a way of finding your child game object to pass as the target for Trigger Custom Event.

There are many ways to find an object in Unity:

  • Direct reference (recommended, faster): Use an object variable that points to your child game object
  • Transform.Find: Pass the path to your child object. For example, Transform.Find("LeftShoulder/Arm/Hand/Finger"). This is simple but slower.
  • Using tags, as you mentioned. Still slower than a direct reference, but probably faster than Transform.Find.

Thanks, i'll try object variable. Should work)

+1

Little tip, for people who are also ain't that smart as myself: 

To access object bellow in the hierarchy (like you want to disable kinematic bool trigger, for example) you'll need to set flow machine on the highest level of the hierarchy, add object variable and the trick is to set it in "Instance", so in this case you can put an object from a lower hierarchy as a value for your gameObject type variable.

Sorry if this is obvious, wasn't for me though)

Thanks a lot! Just saved me like an hour trying to get this right..