playMaker

Author Topic: [SOLVED] set position using string variable  (Read 2753 times)

mrbdrm

  • Playmaker Newbie
  • *
  • Posts: 39
[SOLVED] set position using string variable
« on: June 23, 2012, 06:10:41 AM »
Hello
how can i set the position of a game object passed on only knowing its name and tag ?
PS : i take the name from string variable .
« Last Edit: June 25, 2012, 09:08:40 AM by Alex Chouls »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: set position using string variable
« Reply #1 on: June 23, 2012, 04:39:09 PM »
Hi,

 yes, you have to use the action "find Game Object":

https://hutonggames.fogbugz.com/default.asp?W51

then, you will end up with a reference to the gameObject ( if it exists) and then move it using any of the actions that control the gameObject transform position ( "iTween Move to", "set position", "translate", etc etc)

WARNING: Finding gameObject by name takes a lot of time, don't do it all the time. Find your object once, and then work with the variable. OR create a fsmGameObject variable and drag that gameObject when editing, this will be a lot more efficient. If the gameObject doesn't exists at runtime, considered working out a way to tell the fsm that wants a reference of that new gameObject, by sending an event with the gameObject reference stored in the event data, for example.

 bye,

 Jean

mrbdrm

  • Playmaker Newbie
  • *
  • Posts: 39
Re: set position using string variable
« Reply #2 on: June 24, 2012, 02:50:00 AM »
Thank you jean  :)
i already got the game object name and stored it , the problem is when i try to add the action set position i must provide a game object var it will not take the name and search for the object (because of the time it will take mybe?)
i also tried to create a string var and object var and after i got the name , how to assign the object to the game object var ?

sorry about my ignorant questions  :'(

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: set position using string variable
« Reply #3 on: June 25, 2012, 01:36:49 AM »
Hi,

you need to create a "GameObject" var not a "object" var that's different

exactly using this "Find game Object", have you tried it?

you must first use that action to store the reference of your gameObject in a "gameObject" variable, then you can use "set position" action

Try again, if you can't get it to work, I'll do a working example.

bye,

 Jean


mrbdrm

  • Playmaker Newbie
  • *
  • Posts: 39
Re: set position using string variable
« Reply #4 on: June 25, 2012, 03:32:50 AM »
Hi
it works perfectly now
Thank you  :D