Hey guys, I'm facing a weird behaviour with Playmaker and scriptable objects.
I've made a custom actions to get and set values to scriptable objects that have the same type of the playmaker variables.
When I set that a variable should get the value from the SO every frame, it acts really weird, it set the value the first time you enter state as it should, but when you enter the state again, the value of the Playmaker variable doesn't get updated, this lead to infinite loops when doing some checks.
I'll leave you actions, SOs and FSM screenshots and code so you can have a complete picture of the thing.

Here I have to reset the value of the playmaker variable to 0 or it will bug badly

So code
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[CreateAssetMenu(menuName = "ScriptableObjects/Variables/FloatVariable")]
public class FloatVariable : ScriptableObject
{
public float value;
}
Custom Action Code
using HutongGames.PlayMaker;
using System.Collections;
using System.Collections.Generic;
[ActionCategory(ActionCategory.ScriptControl)]
public class GetFloatVariableValue : FsmStateAction
{
[Tooltip("The value to pass")]
public FloatVariable ScriptableObjectFloat;
[Tooltip("The variable to set")]
public FsmFloat floatVariable;
public FsmBool everyFrame;
public override void Reset()
{
floatVariable = null;
everyFrame = false;
}
public override void OnEnter()
{
if (!everyFrame.Value)
{
SetValue();
Finish();
}
}
public override void OnUpdate()
{
if (everyFrame.Value)
{
SetValue();
}
}
private void SetValue()
{
if (ScriptableObjectFloat != null)
{
floatVariable.Value = ScriptableObjectFloat.value;
}
}
}
using HutongGames.PlayMaker;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[ActionCategory(ActionCategory.ScriptControl)]
public class SetFloatVariableValue : FsmStateAction
{
public FloatVariable ScriptableObjectFloat;
public FsmFloat FloatVariable;
public FsmBool everyFrame;
public override void Reset()
{
FloatVariable = null;
everyFrame = false;
}
public override void OnEnter()
{
if (!everyFrame.Value)
{
SetValue();
Finish();
}
}
public override void OnUpdate()
{
if (everyFrame.Value)
{
SetValue();
}
}
private void SetValue()
{
if (ScriptableObjectFloat != null)
{
ScriptableObjectFloat.value = FloatVariable.Value;
}
}
}
I was testing stuff with another project and I think the problem might be a concurrency of the actions, because FSM variables get updated, but still it keeps going crazy. If I want the Comparison on the vector2 every frame but it must happens after all the actions are done, what I must do?
I'm sorry if it might seems a stupid question but I'm used to normal code where things happens in order (here seems not), I'm new to playmaker and trying to learn the ropes.
