playMaker

Author Topic: Selecting Prefab Children for a Game Object Variable [SOLVED]  (Read 146 times)

acornbringer

  • Junior Playmaker
  • **
  • Posts: 58
    • View Profile
    • Acornbringer.com
Selecting Prefab Children for a Game Object Variable [SOLVED]
« on: August 27, 2019, 11:08:50 AM »
Hello!

Is there some way to select grand-children of a prefab to use in a state that calls for a game object reference?



I'm always running into this issue where I need to tell one FSM of a parent object to look at one of it's grand-children to use in an action. Usually I can drag and drop the prefab or one of it's children into the Game Object field in an action, but with grand-children, I don't see a way to place them there.

One thing I found was that I can select the grand-child object in the scene view then press the "Select" Prefab option in the inspector. I can edit the object from there but that's it; there doesn't seem to be a way to drop it into a PlayMaker action field.

Is there a solution to this or has someone found a work-around that might help me out?

--

Using Unity 5.6.4
Using PlayMaker 1.8.9
« Last Edit: August 28, 2019, 05:06:38 AM by acornbringer »

daniellogin

  • Full Member
  • ***
  • Posts: 166
    • View Profile
Re: Selecting Prefab Children for a Game Object Variable
« Reply #1 on: August 28, 2019, 12:05:15 AM »
To be honest you are confusing me, but I think you may be missing an important point:

You cannot drag select a prefab from the library into an action for an object in the scene, unless it's a simple Create Object action.

So you can say "create X prefab object from library", but you can say "get the position of X prefab that isn't in the game yet" or etc.

However the prefab object itself can see and communicate to it's children. The easiest way to set this up is like this:

* Place the prefab in your scene
* Edit that object in the scene. Playmaker will say you are editing a prefab, say edit instance.
* Drag select it's children from the scene and not the library
* When you are done, use the apply button in the Inspector to make the changes to the object in the scene apply to the prefab

If you do it that way, you will avoid any confusion about what is being changed and how parts are being identified.

As far as Activate Game Object goes, that certainly won't work. The object isn't just disabled if it's in the game library, it's flat out not in the game (scene) yet to even turn on. You would have to instantiate it (create object) to make it in your game, and thus able to have a status such as inactive or active.

The answer to you ultimate question (that you didn't ask) will depend on what exactly you are trying to achieve, not how you are currently trying to achieve it.

When you are trying to activate a child object, is this expected to occur to multiple instances of the prefab that are currently in the scene? Or is it for just select instances of the prefab, and others in the scene aren't meant to be effected?

I think maybe the best place for you to start is describe what you want the game to do, and then everyone can help with suggestions on how we would do that.





acornbringer

  • Junior Playmaker
  • **
  • Posts: 58
    • View Profile
    • Acornbringer.com
Re: Selecting Prefab Children for a Game Object Variable
« Reply #2 on: August 28, 2019, 04:43:17 AM »
Sorry for not being more clear and providing an example. This is a general confusion I have been working around for a while so I just used the basic example of dragging a prefab into the game object field which is essentially what I need to achieve.

A quick example of what I wanted to do: Say I have an enemy character prefab who has a point light attached to his head joint nested way deep down in the hierarchy of the game object. If I want to access some of it's properties, I couldn't reference it in an action on the main FSM attached to the parent through the project window because there's no way of inputting that point light game object into the game object field.

What you explained did help me out however:
[...]
However the prefab object itself can see and communicate to it's children. The easiest way to set this up is like this:

* Place the prefab in your scene
* Edit that object in the scene. Playmaker will say you are editing a prefab, say edit instance.
* Drag select it's children from the scene and not the library
* When you are done, use the apply button in the Inspector to make the changes to the object in the scene apply to the prefab

If you do it that way, you will avoid any confusion about what is being changed and how parts are being identified.
[...]

This is exactly what I was looking for. I was unaware of this functionality and by editing the prefab instance then applying the change, I can make references to objects within the prefab without loosing the connection on start.

Thanks for the help :)

daniellogin

  • Full Member
  • ***
  • Posts: 166
    • View Profile
Re: Selecting Prefab Children for a Game Object Variable
« Reply #3 on: August 28, 2019, 04:56:11 AM »
No problem. So I think you are all sorted now then? Ask away if you have any other questions. This forum is a pretty good place to get help.

acornbringer

  • Junior Playmaker
  • **
  • Posts: 58
    • View Profile
    • Acornbringer.com
Re: Selecting Prefab Children for a Game Object Variable
« Reply #4 on: August 28, 2019, 05:06:18 AM »
Yes! Thank you! I'm going back through my project now and correcting all the funny workarounds I put in before.