- Home /
Organizing Enemy Movement Types
I am looking to implement multiple enemy movements in my game and I was wondering the best way for me to implement this. I want to set it up in a way that I can apply this to any enemy and it is easy for a level designer to select the movement behaviour while building levels.
I have 2 enums one called MovementType, and the other called ActivationType (To set how a MovementType can be switched)
public enum MovementType{ Stationary, Hover, SwitchLane, MoveToPlayer, Wave, CrossLane}
public enum MovementActivationType {DistanceToPlayer, TimeAlive, CollisionWithObject}
In the inspector, I plan to have these enum selections:
DefaultMovementType
ActivationType
SecondaryMovementType
Example:
DefaultMovementType: MovementType.Stationary ActivationType: MovementActivationType.DistanceToPlayer SecondaryMovementType:MovementType.MoveToPlayer
The Object will Spawn and stay still. Code will look for when player is in proximity. Object will start moving towards player
My question is what is the best method for organizing and implementing the different MovementTypes?
My first thought would to have a method that runs on update “DoMove(CurrentMovementType);”
DoMove() would have a switch statement and execute each movement from within this switch. I know this would work, but I am not sure how it will perform in the long run. If you know of a different/better way to do this, I would appreciate it if you could point me in the right direction. If my question isn’t clear enough, let me know and I will try to explain further.
Thanks in advance!