Playmaker Forum

PlayMaker Feedback => Action Requests => Topic started by: mweyna on February 08, 2014, 04:25:48 PM

Title: String Variable to Game Object.
Post by: mweyna on February 08, 2014, 04:25:48 PM
String to Game Object action. Set Name only appears to work if the object exists in the scene already.

I'm trying to set a String variable to a name of the Pre-fab obect (one not in the scene yet), but can't find a reliable way to do the conversion.
Title: Re: String Variable to Game Object.
Post by: jeanfabre on February 10, 2014, 02:54:16 AM
Hi,

 I am confused. "Set Name" only set the name of a gameobject you already have a reference to.

Use "find GameObject" or "Find Child" to search the scene for a gameobject of a specific name.

Bye,

 Jean
Title: Re: String Variable to Game Object.
Post by: mweyna on February 10, 2014, 01:39:37 PM
So I managed to create a workout with a bunch of new things, but findGameObject or FindChild as you said only works for scene objects. I was trying to find a prefab object with a particular string name.
Title: Re: String Variable to Game Object.
Post by: Lane on February 10, 2014, 02:22:56 PM
Since prefabs are static during runtime you can define them explicitly, there is no need to search for one.
Title: Re: String Variable to Game Object.
Post by: jeanfabre on February 11, 2014, 06:42:33 AM
Hi,

 or you can use this action which loads a prefab from the "Resources" by its name:

http://hutonggames.com/playmakerforum/index.php?topic=3916.msg18214#msg18214

Warning, "Resources" is a special thing to learn from first:
https://docs.unity3d.com/Documentation/ScriptReference/Resources.html

bye,

 Jean
Title: Re: String Variable to Game Object.
Post by: mweyna on February 12, 2014, 01:13:18 AM
So I found a workaround which solves it (although probably not the most effective way). Each Prefab I create has a preset String variable called prefab.name.string. When I create the object, I add that name to a fairly often updated Array, along with other stats of that item. When I then load it, I get the original object name (since all the files are in seperate folders based on the item name, not prefab name), then load that prefab.name.string to spawn using my PoolManager. Then just load all the specific attributes to it. It's a pretty heavy FSM, but gets the job done.