playMaker

Author Topic: [SOLVED] Custom action will only run update once  (Read 2023 times)

Disastercake

  • Full Member
  • ***
  • Posts: 101
  • www.disastercake.com
    • Disastercake
[SOLVED] Custom action will only run update once
« on: May 11, 2012, 09:40:52 PM »
When I run this custom action without the everyFrame check box clicked, the debug line will never show in the console (which is intended).  However, when I click the everyFrame checkbox, the console only shows the debug line once.  Any idea why?  Here is my code:

Code: [Select]
public class GetCurrentHP : FsmStateAction
{
//Public
[RequiredField]
public FsmGameObject gameObject;
[RequiredField]
[UIHint(UIHint.Variable)]
public FsmFloat storeValue;
public bool everyFrame;

//Private
float unitinfoValue;
UnitInfo varUnitInfo;
string strDebug;

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

public override void OnEnter()
{
varUnitInfo = gameObject.Value.GetComponent<UnitInfo>();
unitinfoValue = varUnitInfo.GetMaxHealth();
storeValue.Value = unitinfoValue;

if (!everyFrame)
Finish();
}

public override void OnUpdate()
{
varUnitInfo = gameObject.Value.GetComponent<UnitInfo>();
unitinfoValue = varUnitInfo.GetMaxHealth();
storeValue.Value = unitinfoValue;
//Debug
strDebug = Convert.ToString(storeValue.Value);
Debug.Log("Running OnUpdate() and the value is "+strDebug);
}
}
}
« Last Edit: May 11, 2012, 09:48:41 PM by Disastercake »
Soul Saga - Anime themed adventure RPG by Disastercake

http://www.disastercake.com

Disastercake

  • Full Member
  • ***
  • Posts: 101
  • www.disastercake.com
    • Disastercake
Re: Custom action will only run update once
« Reply #1 on: May 11, 2012, 09:48:31 PM »
I guess the Unity debug console doesn't stack messages and just updates them.  This code is actually updating properly.  Silly me =P
Soul Saga - Anime themed adventure RPG by Disastercake

http://www.disastercake.com