playMaker

Author Topic: [SOLVED] Refer to a specific created object  (Read 2624 times)

Megisto

  • Playmaker Newbie
  • *
  • Posts: 28
[SOLVED] Refer to a specific created object
« on: April 27, 2012, 07:10:39 PM »
If i create several objects from single prefab using "CreateObject" action, how can i refer to a specific one of these created?

They come all with the same name, i don't know how to make just one of them do something specific runtime.
« Last Edit: April 30, 2012, 08:15:41 AM by Alex Chouls »

justifun

  • 1.2 Beta
  • Sr. Member
  • *
  • Posts: 280
Re: Refer to a specific created object
« Reply #1 on: April 28, 2012, 11:06:06 AM »
In the "store" section of the create object action that give you the ability to remember the name of the object that was just created.  you could immediately change its name using "set name" afterwards before making the next one.

If you combine an "int add" action as well as a "string build" action, you could take that name and increment its number by 1 over and over each time a new object is created.

so for example, your state that creates the objects would have the following actions

Create object (store name as gameobject)
get name (of game object just made)
Int add +1
Convert Int to string
Build string (game object name plus int)
set name (to the built string you just made)


Also When the newly a created prefab object is created it will automatically start executing its first "start" state if you have a FSM on it.  So you could use that opportunity to rename it or whatever else as well.

Megisto

  • Playmaker Newbie
  • *
  • Posts: 28
Re: Refer to a specific created object
« Reply #2 on: April 28, 2012, 01:19:45 PM »
I understand the logic. I'll try.

Thank you.

Megisto

  • Playmaker Newbie
  • *
  • Posts: 28
Re: Refer to a specific created object
« Reply #3 on: April 30, 2012, 03:51:59 AM »
Thank you, it work like a charm.