playMaker

Author Topic: [Solved] How do you get the owner of a component?  (Read 3493 times)

Disastercake

  • Full Member
  • ***
  • Posts: 101
  • www.disastercake.com
    • Disastercake
[Solved] How do you get the owner of a component?
« 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.
« Last Edit: May 23, 2012, 12:45:41 AM by Disastercake »
Soul Saga - Anime themed adventure RPG by Disastercake

http://www.disastercake.com

iPetProjectDev

  • Playmaker Newbie
  • *
  • Posts: 23
Re: How do you get the owner of a component?
« Reply #1 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

Disastercake

  • Full Member
  • ***
  • Posts: 101
  • www.disastercake.com
    • Disastercake
Re: How do you get the owner of a component?
« Reply #2 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.
Soul Saga - Anime themed adventure RPG by Disastercake

http://www.disastercake.com

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 4000
  • Official Playmaker Support
    • LinkedIn
Re: How do you get the owner of a component?
« Reply #3 on: May 23, 2012, 12:27:26 AM »
Not at my computer, but try Fsm.gameObject.
« Last Edit: May 23, 2012, 12:30:01 AM by Alex Chouls »

Disastercake

  • Full Member
  • ***
  • Posts: 101
  • www.disastercake.com
    • Disastercake
Re: How do you get the owner of a component?
« Reply #4 on: May 23, 2012, 12:45:31 AM »
I ended up using transform.gameobject and it worked. =D
Soul Saga - Anime themed adventure RPG by Disastercake

http://www.disastercake.com

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 4000
  • Official Playmaker Support
    • LinkedIn
Re: [Solved] How do you get the owner of a component?
« Reply #5 on: May 23, 2012, 12:59:51 AM »
Cool. I thought you meant from inside a custom action...