Hi Guys,
I am trying to create a custom script for playmaker that will have points increase over time and display it via the HUD Text plugin.
So I would have 3 states in playmaker.
#1 would go +1 +2 +3 +4
and you would exit out of this state via a wait action
#2 would have the +5 pause for a few seconds to allow people to get the optimum score
#3 would start taking away points +4 +3 +2 +1
Hope this makes sense what I am trying to do. Basically there is a cooking mini game and I am trying to show the points above the food. You get less time if you take it out too soon or too late.
using UnityEngine;
namespace HutongGames.PlayMaker.Actions
{
[ActionCategory(ActionCategory.ScriptControl)]
[Tooltip("Call Add of HUDText.")]
public class HUDTextNumbers : FsmStateAction
{
[RequiredField]
[CheckForComponent
(typeof(HUDText
))] public FsmOwnerDefault gameObject;
public FsmFloat value;
public FsmFloat addValue;
public FsmFloat results;
public FsmColor col;
public FsmFloat timeBeforeNextText;
public FsmFloat timeBeforeFade;
private float timer;
public override void Reset()
{
}
public override void OnUpdate()
{
// check that we have MyScript referenced
GameObject go = Fsm.GetOwnerDefaultTarget(gameObject);
if (go == null)
{
return;
}
HUDText hudtext = go.GetComponent<HUDText>();
if (hudtext == null)
{
return;
}
timer += Time.deltaTime;
if (timer >= timeBeforeNextText.Value)
{
timer = 0f;
results = value.Value + addValue.Value;
hudtext.Add(value.Value + addValue.Value,col.Value,timeBeforeFade.Value);
}
}
}
}