playMaker

Author Topic: Possible to convert FSMGameObject into FsmOwnerDefault?[SOLVED]  (Read 3872 times)

amaranth

  • Full Member
  • ***
  • Posts: 172
Just curious about how to do this inside an action script.

For example:

private FsmOwnerDefault gameObject1;
private FsmGameObject gameObject2;

gameObject1 = gameObject2;

(won't work, I always get errors. I'm not sure how to make the conversion.)

« Last Edit: August 14, 2012, 02:52:44 AM by jeanfabre »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Possible to convert FSMGameObject into FsmOwnerDefault?
« Reply #1 on: August 10, 2012, 02:32:40 AM »
Hi,

 Do the following:

Code: [Select]

var go1 = Fsm.GetOwnerDefaultTarget(gameObject1);
gameObject2.Value = go1;


Bye,

 Jean

amaranth

  • Full Member
  • ***
  • Posts: 172
Re: Possible to convert FSMGameObject into FsmOwnerDefault?
« Reply #2 on: August 10, 2012, 02:10:53 PM »
Think I need to rephrase what I'm asking... I'm trying to figure out a way to convert a Fsm Game Object into a Fsm Owner Default.

Code: [Select]
private FsmOwnerDefault parentGameObject;
private FsmGameObject childGameObject;

// This dies because childGameObject is not a FsmOwnerDefault.
// I'm not sure how else to assign targetObject to childGameObject
// w/o using GetOwnerDefaultTarget.

var targetObject = Fsm.GetOwnerDefaultTarget(childGameObject);
storeComponent.Value = targetObject.GetComponent(storeComponent.ObjectType);

(What I'm actually trying to do is create an action that changes the icon attached to an NGUI button. To do this, I have to reference the parent button game object, then drop down to the child icon game object, then grab a script object that controls which bitmap is displayed for the icon.)

I've attached a WIP of the script. It's about half written (or copied/pasted from GetChild & SetProperty)
« Last Edit: August 10, 2012, 02:17:10 PM by amaranth »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Possible to convert FSMGameObject into FsmOwnerDefault?
« Reply #3 on: August 13, 2012, 03:54:35 AM »
Hi,

 then my example is really what you need.

 you don't want to transform a FsmGameObject into a FsmOwnerDefault, what you want is getting to the gameObject reference for both.

 so to get the child GameObject

var childObject  = childGameObject.Value

and to get the parentGameObject:

var parentObject = Fsm.GetOwnerDefaultTarget(parentGameObject);

bye,

 Jean

amaranth

  • Full Member
  • ***
  • Posts: 172
Re: Possible to convert FSMGameObject into FsmOwnerDefault?
« Reply #4 on: August 13, 2012, 12:14:32 PM »
It's the oddest thing. I thought I'd already tried that, but this morning, I plugged it in and everything worked great! My poor brain must have been fried by the end of last week. Thank you for the refresh!