playMaker

Author Topic: Convert Variable GameObject to a variable Object[SOLVED]  (Read 3476 times)

Sly

  • Full Member
  • ***
  • Posts: 123
Convert Variable GameObject to a variable Object[SOLVED]
« on: February 05, 2014, 03:32:40 PM »
Hello,

I have some problem to convert a variable type gameobject to a variable type object.

For this I'm using the action Find closest. So I want to store the closest gameobject to a value and this value will be set to a "Set property cation", and so change the target of a script.
My situation is I'm using the action Set property for changing target to a script (the target in the script is UnityEngine.Transform).
I don't know how to transfert this closest gameobject to the unityengine.transform.

Is it possible to convert my gameobject variable value to an object variable?

Or can I do this in a different way?
Thanks

PS: I hope I explain well my problem, cause it's a tough one I guess.
« Last Edit: February 10, 2014, 03:21:54 AM by jeanfabre »

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: Convert Variable GameObject to a variable Object
« Reply #1 on: February 05, 2014, 04:01:16 PM »
The script you want to affect is a Component on the GameObject, so you need to make a component variable that defines it and then fill it.

Strange that all these GameObject > Object threads are appearing. Admittedly, I don't think I'm fully aware of the correct setup as some things didnt work as I expected.
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Convert Variable GameObject to a variable Object
« Reply #2 on: February 07, 2014, 07:38:29 AM »
Hi,

 for this, you have to use "Get component" action, a transform can be saved in a FsmObject, and to get it from a FsmGamObject, you use "Get component" and that will work.

an example can be found on this thread:

http://hutonggames.com/playmakerforum/index.php?topic=6246.msg30566#msg30566

it will save a gamobject as a transform to pass it to a script that only accepts transforms.

bye,

 Jean


Sly

  • Full Member
  • ***
  • Posts: 123
Re: Convert Variable GameObject to a variable Object
« Reply #3 on: February 07, 2014, 03:37:18 PM »
That's a perfect method for what I want.
Get Transform and store the gameobject variable to a transform variable. So I can set to my component the target I want with Set property action.

Note: Transform variable are in fact Object variable. Set UnityEngine.Transform in field Object Type. See picture attached.

I just explain a little bit because it's a little bit tricky to understand but do-able.

Merci Jean!