I’m using a state machine. There is a “ClassName : FSMSystem” that is attached to a GameObject. Then I have “StateName : FSMState”, but I can’t use anything from MonoBehaviour in this state, only in the main FSMSystem class.
using UnityEngine;
using System.Collections;
public class PlayerScript : FSMSystem {
// STATES
public PlayerIdle S_PlayerIdle;
void Awake()
{
AddState(S_PlayerIdle);
S_PlayerIdle.Parent = this;
GoToState(S_PlayerIdle);
}
}
FSMSystem inherits from MonoBehaviour, so it has access to Instantiate. FSMState does not. Here is an example state script:
using UnityEngine;
using System.Collections;
[System.Serializable]
public class PlayerIdle : FSMState {
[System.NonSerialized]
public PlayerScript Parent;
public override void OnEnter()
{
}
public override void OnUpdate()
{
}
public override void OnExit()
{
}
}
I can’t make FSMState inherit from MonoBehaviour, so how do I get access to Instantiate/etc?