- Home /
Calling a function outside the Finite State Machine
Hello all,
I have a FSM (Finite State Machine) scripts that have my AI move from one state to another.
But, one of them is called from an outside script.
Here's the layout with pieces of code in chronological order: A: I call the function from the out side script (MonoBehaviour):
if (Vector3.Distance(transform.position, target) <= minDistance)
{
avatar.GoToSpecificPoint(target, transform);
B: The function is then redirected to the "main script" of the FSM (MonoBehaviour):
public void GoToSpecificPoint(Vector3 target, Transform player)
{
currentState = goToSpecificPoint;
goToSpecificPoint.SpecificPoint(target, player);
}
C: The function is then redirected to the goToSpecificPoint state(Interface):
public void SpecificPoint(Vector3 target, Transform player)
{
playerTransform = player;
targetLocation = target;
shopper.navMeshAgent.destination = targetLocation;
}
Someone help me write this path, and I don't like it. I don't want the function "SpecificPoint" to be called directly from B part, I want it to be called from the Update function of the C part, aka the actual state. BUT for some reason it wont let me assign this function from the Update() telling me that it takes arguments, and when I declare them it says that it's the wrong context.
Your answer
Follow this Question
Related Questions
Distribute terrain in zones 3 Answers
GOAP - how can you change the state outside of an action? 1 Answer
Double reference to waypoints in FSM 0 Answers
Multiple Cars not working 1 Answer
How to make a List or Array of functions with type Void 4 Answers