I want to access an enum I have on another script. I see a common solution is to make it a static, but this won’t work because I’m using it on multiple game objects.
Basically I have two state machines that are layered on one another.
One decides the general state (engage the player, disengage the player, search for the player, return to the start position, and dead) while the other picks specific actions to be used during these general states (move, jump, chase, dodge, attack).
So I need to pull the general states onto the script giving specific actions.
Is there a better method I should be using here?
Here’s the enum on the general states script:
public class Enemy_Stats : MonoBehaviour {
public enum State { DisengagedState, EngagedState, SearchState, ReturnState, DeadState };
public State myState;
And here’s the script that I want to access it on:
public class Enemy_Large_Spider : MonoBehaviour {
public float movementSpeed;
public float turnSpeed;
private Vector3 targetPosition;
public int damage;
public enum _State{ IdolState, MovingState, ChaseState, DodgeState, JumpState, ShootState };
public _State myState;
I’m half tempted to use a byte instead and just make note on what each number corresponding state is, but I would really like to learn how to do it the “correct” way.
Any suggestions?