Mob Controller Overview
The Atavism Mob Controller is used to manage the movement and animations of mobs (mobile objects such as playable characters and AI NPCs etc). The mob controller gets in movement information about the mob from either the input controller (for the local player) or from the Atavism Core (which gets the movement data from the server) and moves the mob. It then works out what animation should be played based on the current movement of the mob and any other animation override settings.
Each mob needs a script on it that extends the AtavismMobController class. If no such script is found on a mob, the mob will not move or play any animations and Unity will produce many errors.
Note: The Mob Controller does not send any data to the server. It is an input only system that takes information from the server and the local client and moves the mob and plays animations on the local client only.
How it Works
Note: This description covers how the default MobController3D script works.
Upon start-up, the script determines whether it should be using the legacy Animation system, or the new Animator system Unity provides by checking for what other components are on the object. It also registers for a few properties and sets itself to not collide with other mobs.
The bulk of work occurs in the Update() function. This function, which is run every frame, first gets the desired movement of the mob. It checks if it is a player, and if so, it gets the movement from the Input Controller component on the mob, or it checks to see what movement data has been set from the server. It then applies gravity and comes up with a final desired movement Vector (x, y, z).
After the desired movement is determined, it gets the Character Controller component on the mob and calls Move() passing in the desired movement Vector. This is the line of code that actually moves the object in the scene.
Once the movement has been applied, it works out which animation should be done (still in the Update() function). Depending on which animation system is being used, different code is run. You can find more about this on the Working with Animations page.
There is also a small section of code in the OnGUI() function which is used to draw the name of a mob above it and display combat damage text as well. This may get changed in the future.