Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: amaranth on August 09, 2012, 08:32:55 PM

Title: Possible to convert FSMGameObject into FsmOwnerDefault?[SOLVED]
Post by: amaranth on August 09, 2012, 08:32:55 PM
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.)

Title: Re: Possible to convert FSMGameObject into FsmOwnerDefault?
Post by: jeanfabre on August 10, 2012, 02:32:40 AM
Hi,

 Do the following:

Code: [Select]

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


Bye,

 Jean
Title: Re: Possible to convert FSMGameObject into FsmOwnerDefault?
Post by: amaranth 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)
Title: Re: Possible to convert FSMGameObject into FsmOwnerDefault?
Post by: jeanfabre 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
Title: Re: Possible to convert FSMGameObject into FsmOwnerDefault?
Post by: amaranth 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!