playMaker

Author Topic: Activate gameobject based on a string name variable? [SOLVED]  (Read 1662 times)

adre

  • Playmaker Newbie
  • *
  • Posts: 20
Activate gameobject based on a string name variable? [SOLVED]
« on: February 07, 2018, 11:22:21 AM »
Hello,

If the string variable is Gameobject01 , i would like to activate Gameobject01
if Gameobject02, i would like to activate Gameobject02.

I tried this with Find Game Object action without luck..
In this action,I put the string variable, made a custom tag and defined it and told it to store as a gameobject. And told Activate Game Object to activate this gameobject variable.

But when i hit "play" , i see that it is not stored in Find Game Object. It says "none".  So the Activate Game Object action doesn't work because it also says "none".

Any ideas? Am i lacking something?

Plus; after this, how do i disable the rest of the GameObjects that have the same tag?

Thanks a lot!
« Last Edit: February 07, 2018, 01:13:10 PM by adre »

miguelfanclub

  • Full Member
  • ***
  • Posts: 165
Re: Activate gameobject based on a string name variable?
« Reply #1 on: February 07, 2018, 12:14:46 PM »
I think you should look into arraymaker to do this.

https://www.youtube.com/watch?v=6SBuH1vxC7A


GonerGames

  • Junior Playmaker
  • **
  • Posts: 53
Re: Activate gameobject based on a string name variable?
« Reply #2 on: February 07, 2018, 12:32:24 PM »
The Action Find Game Object will not return a result if the Parent object is deactivated.
One way to handle this is to create and empty game object that is always active and then put the items you want to activate/deactivate as children of this object.
eg. Parent Empty "Items"
Children - "GameObj01", "GameObj02" etc.

Then your FSM will look like

Find Game Object:
Object Name -> "Items"
With Tag -> (your tag here)
Store as "Parent_Object"

Find Child:
Game Object -> Specify -> Parent_Object
Child Name -> "Gameobj01" (or from a custom combine string)
Store -> Child_object

Activate Game Object:
Game Object -> Specify Object -> Child_Object
Activate -> On or off

adre

  • Playmaker Newbie
  • *
  • Posts: 20
Re: Activate gameobject based on a string name variable?
« Reply #3 on: February 07, 2018, 12:59:34 PM »
The Action Find Game Object will not return a result if the Parent object is deactivated.
One way to handle this is to create and empty game object that is always active and then put the items you want to activate/deactivate as children of this object.
eg. Parent Empty "Items"
Children - "GameObj01", "GameObj02" etc.

Then your FSM will look like

Find Game Object:
Object Name -> "Items"
With Tag -> (your tag here)
Store as "Parent_Object"

Find Child:
Game Object -> Specify -> Parent_Object
Child Name -> "Gameobj01" (or from a custom combine string)
Store -> Child_object

Activate Game Object:
Game Object -> Specify Object -> Child_Object
Activate -> On or off

Find Child worked for me! Thanks a lot!

Both Find Game Object and Find Game Object2 still doesn't work for me, either when the gameobjects are in the root or under a parent object (which i should use Find Child as you stated)

I first used Activate Children to deactivate all the children, and then Find Child and activated the gameobject.
« Last Edit: February 07, 2018, 01:16:33 PM by adre »