playMaker

Author Topic: Select a GameObject in a script  (Read 4977 times)

Loic Joint

  • Junior Playmaker
  • **
  • Posts: 76
Select a GameObject in a script
« on: November 29, 2011, 05:18:39 AM »
Hello,

I try to change the GameObject of a script in the initialisation of my scene whith Playmaker, is it possible ?

Thanks !
LOIC

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Select a GameObject in a script
« Reply #1 on: November 30, 2011, 02:27:34 AM »
Hi,

 yes it's possible :)

 create a fsm variable of type "object"

set the object type to your script then select the gameObject where this script is attached. WARNING if two of these script are attached to the saem gameObject, it will pick only one ( stunning miss from unity editor!! unless I am blind)

now, use the set property action, set it to use your variable defined above, then pick the property you want to  set ( it will list all public property of your script, how cool is that!) and set it and done.

 Is that what you wanted to achieve?

 Bye,

 Jean

Loic Joint

  • Junior Playmaker
  • **
  • Posts: 76
Re: Select a GameObject in a script
« Reply #2 on: December 01, 2011, 08:45:51 AM »
Hi,

Thanks for your very apreciated help !

I have try this method, but if I remplace the GameObject variable type in the script by a "Object" variable type, the script turn invalide. (this is "simplepath", I try to change the gameobject in the "interaction chase" agent).

Unity say the script use a "MoveToGameObject" and that not compatible with a "Object" variable type.

There is a solution for the problem ?

Thank again for your precious help !


jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Select a GameObject in a script
« Reply #3 on: December 02, 2011, 12:35:41 AM »
Hi,

Where did you get that simplePath script? I double checked that it was working with javascript and it does. but maybe this script is not.

Can you send me that script and I'll have a test locally to try and replicate your issue.

 Bye,

 Jean

Loic Joint

  • Junior Playmaker
  • **
  • Posts: 76
Re: Select a GameObject in a script
« Reply #4 on: December 02, 2011, 05:33:58 AM »
Hi,

This script is in the exemples/code folder of simple script, but I'm probably made a mistake of newby ^^

The location of the gameObject in the script :


I contact you by MP, thank you very much !

bye,
LOIC

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Select a GameObject in a script
« Reply #5 on: December 05, 2011, 12:15:15 AM »
Hi,

I might not have been clear enough :)

The object type of the object variable must be of Interaction_chase, then you can access it's variable

I have attached to this post the screenshot of my set up for the variable and how I access it in the state.

 Hopefully this will guide you. If not get back to me and we'll arrange something so that it works for you.

 Bye,

 Jean

Loic Joint

  • Junior Playmaker
  • **
  • Posts: 76
Re: Select a GameObject in a script
« Reply #6 on: December 05, 2011, 03:28:01 AM »
Hi,

That work ! I did not know the object variable Should be configured ^^

Thank you very much !

Bye,
LOIC

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Select a GameObject in a script
« Reply #7 on: December 05, 2011, 07:49:06 AM »
hi,

 Yes the back and forth set up of variable is cumbersome. I whish for example that all the props are available as soon as you create the variable, not having to create, then select, then edit again...

 Bye,

 Jean

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 3987
  • Official Playmaker Support
    • LinkedIn
Re: Select a GameObject in a script
« Reply #8 on: December 10, 2011, 11:45:42 PM »
I've added an option to auto-select newly created variables - I think it works well. Will send out a new beta soon...