Glob
public enum GlobState
{
idle, wander, follow, telegraph, attack, die
}
public class Glob : EnemyNetworkEntity, IHittable, IDamage
{
public AnimationComponent animationComponent;
public sfloat moveSpeed = (sfloat)0.24f;
public int damage = 0;
public HPComponent hpComponent;
public ObjectRect hitBox;
public GlobState state = GlobState.idle;
public float stateTimer = 2;
public PlayerNetworkEntity target = null;
public sfloat maxChaseDistance = (sfloat)10;
public sfloat attackRange = (sfloat)2;
public int attackDamage = 30;
public int attackMoveMultiplier = 4;
public ObjectRect leftCheck, rightCheck, upCheck, downCheck;
//...
This is an example enemy class from the sample project. Unlike the other reference pages, this one will just give a quick run down of interesting sections. Reference NetworkEntity and PlayerNetworkEntity pages for a deeper breakdown.
Glob’s AI is designed to walk around randomly with pauses until a player is nearby, then it moves in for an attack. This logic is helped carried out by the Think() function and state the character is in.
The logic is ran on the server side and animations and positions are lerped on the clients. Globs are using the AnimationComponents I built for the project. If you want to see how to use the Unity animation system on your NetworkEntities, look at GlobKing