playMaker

Author Topic: Ordering and renaming clones? [SOLVED]  (Read 3652 times)

parallel

  • Full Member
  • ***
  • Posts: 155
Ordering and renaming clones? [SOLVED]
« on: March 08, 2013, 07:36:15 PM »
Hi. I'm creating objects at runtime, (spiraling steps) which just list as clones in the main hierarchy. How to put these children to a parent?, can't see the right use of the children/ parent actions which I guess is there for such things. Also how would I go about renaming the created clones, for example nummerically by their created order?
« Last Edit: March 13, 2013, 07:10:36 PM by parallel »

Vallar

  • Junior Playmaker
  • **
  • Posts: 90
Re: Ordering and renaming clones?
« Reply #1 on: March 10, 2013, 04:12:40 PM »
Hello,

To be honest, I haven't used Parent/Child actions before that much, but I believe this should work.

After creating your child object, you can use the "Set Parent" action; save the child in a GameObject variable that is empty and use that variable to populate the parent.
As for changing the name, since you are saving the child in GameObject variable you can use the "Set Name" action to set the name of the object as you please.

Here is an example:
1- Create a variable named childObject (type GameObject).
2- Edit the "Store" option in the "Create Object" action to childObject (saving that specific object you created).
3- Add action "Set Parent" where you choose the parent as you want and the "Game Object" to be the "childObject" variable.
4- Add another action to the same state "Set Name" while choosing the Game Object as the variable "childObject" and enter the name you want in the action.

If you want however the name adding to be more dynamic and not set manually (for loads of objects):
1- Instead of adding the action "Set Name" to the same state, create another variable called nameCount (of type int and set it to 0) and childName (of type string) and nameCountString again (of type string)
2- Create another state (where the previous state we create above would flow into the one we are talking about now) with the action "Int Add".
3- Populate the "Int Add" action with "nameCount" variable and the number to add is 1.
4- Add another action called "Convert Int to String" and use the "nameCount" to change to String stored in "nameCountString"
5- Use the "Build String" action and use "nameCountString" with "childName" and store it in "childName".

I believe the previous methods will help you both create the object on the fly, add it to a fixed parent and rename it both dynamically and statically.

If however, you want the parent to be dynamic as the child, you can create another GameObject variable and set the parent to that as well.


Hope that helps in anyway.

parallel

  • Full Member
  • ***
  • Posts: 155
Re: Ordering and renaming clones?
« Reply #2 on: March 13, 2013, 05:48:12 PM »
Hope that helps in anyway.

It certainly does, wasn't aware of the set name action and didn't know that you could leave a gameobject variable empty. Thanks Vallar!

dubnug

  • Playmaker Newbie
  • *
  • Posts: 22
Re: Ordering and renaming clones? [SOLVED]
« Reply #3 on: August 25, 2013, 01:47:27 PM »
Thank you Vallar!! Dug this up and it solved my problem as well. Cheers  ;D