Hi,
Ok, I think I know why:
a GameObject is not a component, it's the object that has component attached, and as such is not a valid "type" to use with Unity "GetComponent()" method.
if you try do that forcing the type explicitly, it will fire the following:
Assets/PlayMaker/Actions/GetComponent.cs(59,61): error CS0309: The type `UnityEngine.GameObject' must be convertible to `UnityEngine.Component' in order to use it as parameter `T' in the generic type or method `UnityEngine.GameObject.GetComponent<T>()'
So, I think that this is by design and not a bug.
I have added a check to that "Get Component" action to properly account for this case.
Can you have a go and tell me if that works for you ( I tested and it does, but just to make sure I understand what you are after).
Also, what's the point of cube 3 test? do you really need to access a Unityengine.Object?!?
bye,
Jean
ps: until attachment is back again, please find the code source to replace.
// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved.
using UnityEngine;
using System;
namespace HutongGames.PlayMaker.Actions
{
[ActionCategory(ActionCategory.UnityObject)]
[Tooltip("Gets a Component attached to a GameObject 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.")]
public class GetComponent : FsmStateAction
{
[Tooltip("The GameObject that owns the component.")]
public FsmOwnerDefault gameObject;
[UIHint(UIHint.Variable)]
[Tooltip("Store the component in an Object variable.\nNOTE: Set theObject 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.")]
public FsmObject storeComponent;
[Tooltip("Repeat every frame.")]
public bool everyFrame;
public override void Reset()
{
gameObject = null;
storeComponent = null;
everyFrame = false;
}
public override void OnEnter()
{
DoGetComponent();
if (!everyFrame)
{
Finish();
}
}
public override void OnUpdate()
{
DoGetComponent();
}
void DoGetComponent()
{
if (storeComponent == null)
{
return;
}
GameObject targetObject = Fsm.GetOwnerDefaultTarget(gameObject);
if (targetObject == null)
{
return;
}
if (storeComponent.ObjectType == typeof(GameObject))
{
storeComponent.Value = targetObject;
}else{
storeComponent.Value = targetObject.GetComponent(storeComponent.ObjectType);
}
}
}
}