playMaker

Author Topic: Get Component  (Read 2816 times)

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 3207
  • Official Playmaker Support
    • View Profile
    • LinkedIn
Get Component
« on: December 09, 2011, 05:23:32 PM »
Gets a Component on a GameObject at runtime and stores it in an Object variable.

NOTE: Set the Object variable's Object Type to get a component of that type. E.g., set Object Type to UnityEngine.AudioListener to get the AudioListener component on the camera.

HINT: Combine this action with Get Property and Set Property actions to manipulate components on GameObjects.

Andrew_Raphael_Lukasik

  • Full Member
  • ***
  • Posts: 134
    • View Profile
    • my twitter @andrewlukasik
Re: Get Component
« Reply #1 on: December 11, 2011, 03:58:31 PM »
Thank you Alex! I needed that :)

vonchor

  • 1.2 Beta
  • Playmaker Newbie
  • *
  • Posts: 28
    • View Profile
Re: Get Component
« Reply #2 on: January 02, 2012, 06:12:58 PM »
aah, close but no cigar yet  ???

If I attach a script to a game object (say XYZ) and then create an object variable (abc) which I then set to that type using the "edit variable" inspector in the playmaker state editor window, I can then use Set or GetProperty to access a runtime object with a component of that type. The problem is that when authoring that state the Get/SetProperty action lets me set the target object to ABC. The Property selector appears and shows the instance variables for the object. But there's no source or destination for the data. If I use one of the "inherited" variables like gameObject, or transform, the src/destination field appears but doesn't in this case.

If you use Get/SetProperty on GO that's in the Heirarchy, a little dropdown would appear letting you set the dest or source for the access (an int, float, etc). In this case it doesn't show up.

I hope it's just  me misunderstanding this somehow.

Well I thought of something else: I added get{} set{} and it worked. Should have thought of that right off. Sending this along anyway in case someone else gets confused.