I
I
i__egor2020-06-06 17:59:28
Unity
i__egor, 2020-06-06 17:59:28

Who makes states like in unity?

Let's say there is a character (Player class), it contains the FSMPlayer object:

public class FSMPlayer
{
public AStatePlayer state; // текущее состояние
Dictionary<TypeStatePlayer, AStatePlayer > dict_states = new Dictionary<TypeStatePlayer, AStatePlayer >();
public enum TypeStatePlayer{.....}
public void State(TypeStatePlayer type){....}
}

There is an abstract ASTatePlayer and several concrete descendants from it.
Player class inherits from MonoBehaviour, FSMPlayer, AStatePlayer - does not inherit from MonoBehaviour.
Somewhere not in unity this worked fine. But in specific states, it is necessary to control the Player, for this it is necessary that they also inherit from MonoBehaviour. Then all the objects of these classes will have to be created not as new Class(); and through AddComponent to hang somewhere and then enable disable for example?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question