playMaker

Author Topic: get tag 2  (Read 3726 times)

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
get tag 2
« on: December 29, 2011, 01:09:32 AM »
Hi,

 I modified the get tag so that is accepts "owner" for the gameObjet. it's then easier to setup and works well within prefabs.

Code: [Select]
// (c) Copyright HutongGames, LLC 2010-2011. All rights reserved.

using UnityEngine;

namespace HutongGames.PlayMaker.Actions
{
[ActionCategory(ActionCategory.GameObject)]
[Tooltip("Gets a Game Object's Tag and stores it in a String Variable.")]
public class GetTag2 : FsmStateAction
{
[RequiredField]
public FsmOwnerDefault gameObject;
[RequiredField]
[UIHint(UIHint.Variable)]
public FsmString storeResult;
public bool everyFrame;

private GameObject _go;

public override void Reset()
{
gameObject = null;
storeResult = null;
everyFrame = false;
}

public override void OnEnter()
{
_go = gameObject.OwnerOption == OwnerDefaultOption.UseOwner ? Owner : gameObject.GameObject.Value;

DoGetTag();

if (!everyFrame)
Finish();
}

public override void OnUpdate()
{
DoGetTag();
}

void DoGetTag()
{
if (_go == null)
return;

storeResult.Value = _go.tag;
}

}
}

Bye,

 Jean

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 4000
  • Official Playmaker Support
    • LinkedIn
Re: get tag 2
« Reply #1 on: January 02, 2012, 03:05:49 PM »
Cool. I think I'll modify the original action to do this (it should keep existing values when updated, so it shouldn't break existing projects).