playMaker

Author Topic: Playmaker ArrayMaker String to Game Objects  (Read 5082 times)

laynardo

  • Junior Playmaker
  • **
  • Posts: 54
Playmaker ArrayMaker String to Game Objects
« on: February 23, 2016, 05:24:55 PM »
hi,
I have a string I am getting from an input field. I basically want to convert it to game objects pulled dynamically from my prefab folder.

For example, I type in "hello" and click submit. On screen I see a series of game objects laid out in order, that each represent each letter.
h= prefab 1
e= prefab 2
l - prefab 3
and so on.

I honestly am not sure how to do this. I think I use Arraymaker Split text to Array List? but not even sure what to do after that. I am a newbie, and not much of a coder, but I do understand playmaker pretty well.

any help would be super appreciated!

Chizzler

  • Junior Playmaker
  • **
  • Posts: 67
Re: Playmaker ArrayMaker String to Game Objects
« Reply #1 on: February 23, 2016, 05:38:24 PM »
1. Use the "Get String Length" to get the number of characters in your input field. well call this, "int_Length"

2. Create another integer variable "int_Current". We'll be using this to keep track of which character to pull from the string... Also create a string variable "Str_Current" to store that character.

3. Set up a loop:  "Get String Left" and set the parameters so we pull the character using "int_Current" and save the pulled character to "str_Current".  We add this string to an Array, add 1 to "int_Current" and repeat until int_Current = int_Length.

4. Now we have an Array of characters, we can set up a loop (Array Get Next) with a number of "String Compare" actions testing which Prefab we want to create.

laynardo

  • Junior Playmaker
  • **
  • Posts: 54
Re: Playmaker ArrayMaker String to Game Objects
« Reply #2 on: February 25, 2016, 05:15:36 PM »
hey! this was really helpful. I got it mostly working. I used get substring instead to get each letter- it wasn't working right with get string left. Currently, i just have it looking for the letter "a", and once I get everything working, I will create an entire alphabet of game objects.

The challenge i have now, is if I am typing a series of letters, like "aaaaaa", at first it was only putting one prefab one the scene. I made a loop to keep checking for each letter, in order to put 6 letter "a"s on the screen for example, but I broke my FSM. It's in a recursive loop. I know it is something simple, and have put in alot of hours already to figure it out. the file is to big to post, and I stripped it down- maybe you can have a peak and figure out what the issue is.
« Last Edit: February 25, 2016, 06:56:07 PM by laynardo »

Chizzler

  • Junior Playmaker
  • **
  • Posts: 67
Re: Playmaker ArrayMaker String to Game Objects
« Reply #3 on: February 25, 2016, 05:36:37 PM »
You've got a ton of files in that UnityPackage including some playmaker .dll's
Please remove the link, it's got stuff in you don't want to be distributing.

The only things you need to export for me, is the Scene in question, any custom actions used in that scene, and maybe your global variables, if they're used. It helps if they're placed in a seperate folder in your project panel, so it doesn't get scattered around into various places when someone imports it.

Edit: It took a little work to locate the scene in question, and get it running properly in my Playmaker, some variables got wiped... but I think i got it right..

On both your Array Get Next actions, you're storing the Index value, which isn't needed and could be causing an issue. Your also running a Int compare on the "String Compare" state, which again isn't needed. After removing those 2 things, it worked fine in my scene, but i had to fix up some broken values to get it working on my computer so maybe I've missed something (Array's were trying to store floats for example) - Nothing jumped out at me as being able to cause an endless loop though.
« Last Edit: February 25, 2016, 06:21:21 PM by Chizzler »

laynardo

  • Junior Playmaker
  • **
  • Posts: 54
Re: Playmaker ArrayMaker String to Game Objects
« Reply #4 on: February 25, 2016, 06:38:47 PM »
oh. I was trying to figure out the best way to export just the needed files...
can you attach the updated scene for me here?

Chizzler

  • Junior Playmaker
  • **
  • Posts: 67
Re: Playmaker ArrayMaker String to Game Objects
« Reply #5 on: February 25, 2016, 06:50:53 PM »
*Link Removed*

It may need a few things fixing on import again. I think you're using playmaker 1.8?  I'm still on 1.7
Just check to make sure your array's are storing string varaibles like they're supposed too, and that your other variable actions are grabbing the right variable, and it should work =)  I've named the scene differently so it doesn't override your original.
« Last Edit: February 26, 2016, 06:12:37 PM by Chizzler »

laynardo

  • Junior Playmaker
  • **
  • Posts: 54
Re: Playmaker ArrayMaker String to Game Objects
« Reply #6 on: February 25, 2016, 06:56:39 PM »
link removed and downloading.

Chizzler

  • Junior Playmaker
  • **
  • Posts: 67
Re: Playmaker ArrayMaker String to Game Objects
« Reply #7 on: February 25, 2016, 07:08:50 PM »
Cheers =)    If text doesn't appear when you type, it's because I didn't import your font with the package, and had to switch it to one I had.  Just switch it back to your chosen font on the "faketype" input box

laynardo

  • Junior Playmaker
  • **
  • Posts: 54
Re: Playmaker ArrayMaker String to Game Objects
« Reply #8 on: February 25, 2016, 07:56:42 PM »
works! weird thing though- it keeps adding a Playmaker UGui to the hierarchy. don't I already have it?

Chizzler

  • Junior Playmaker
  • **
  • Posts: 67
Re: Playmaker ArrayMaker String to Game Objects
« Reply #9 on: February 25, 2016, 08:10:47 PM »
Awesome =)

You had a Playmaker GUI prefab (which I deactivated) which isn't the same thing. the new UI system needs the Playmaker uGUI scene proxy, which is included in the prefab that keeps getting added.  there's an option in playmaker preferences somewhere to stop it automatically adding it to a scene.
« Last Edit: February 25, 2016, 08:19:16 PM by Chizzler »

laynardo

  • Junior Playmaker
  • **
  • Posts: 54
Re: Playmaker ArrayMaker String to Game Objects
« Reply #10 on: February 26, 2016, 05:23:38 PM »
thx again! all good here. I'll post the finished piece for everyone soon! I could have some more questions though, hope not.