Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: Disastercake on May 22, 2012, 10:34:27 PM

Title: [Solved] How do you get the owner of a component?
Post by: Disastercake on May 22, 2012, 10:34:27 PM
This is more of a Unity scripting question than a Playmaker one, but since I spend most my time here... =P

How do I grab the owner of a scripting component in the code?  Basically I just want to send the owner via code to another method in another object's component.
Title: Re: How do you get the owner of a component?
Post by: iPetProjectDev on May 22, 2012, 11:24:44 PM
I am new to this but catching on quickly. I believe you would place and Fsm component on that object with the script or component you are targeting and then drag the script into the actions field and it give you a choice to get or set properties. in this case GetProperty and then create a Global Variable for that property to address from other Fsm's.. Is that what you are after?



HTH
Title: Re: How do you get the owner of a component?
Post by: Disastercake on May 22, 2012, 11:28:52 PM
Well if I was using Playmaker for this part of my code, there's actually a "GetOwner" action that works perfectly.  Unfortunately a lot of my code is in custom actions or in separate scripts and I mostly use Playmaker for flowcharting.

So what I need is the code used ina custom C# script that grabs the gameobject that script is attached to, since it will be attached to multiple objects, I want each instance to grab it's own owner.
Title: Re: How do you get the owner of a component?
Post by: Alex Chouls on May 23, 2012, 12:27:26 AM
Not at my computer, but try Fsm.gameObject.
Title: Re: How do you get the owner of a component?
Post by: Disastercake on May 23, 2012, 12:45:31 AM
I ended up using transform.gameobject and it worked. =D
Title: Re: [Solved] How do you get the owner of a component?
Post by: Alex Chouls on May 23, 2012, 12:59:51 AM
Cool. I thought you meant from inside a custom action...