Actor system is the core of this kit, since it controls all Player and AI movements/actions.
It's extremely flexible Mecanim-based system, but it can be tricky in setup. System consists from 3 main components:
- Animator - linked with Mecanim and controlled by objects in Controller and Avatar properties - ActorAnimator - linked with Animator to process all action-related animations and call actions - ActorBehavior - linked to Actor Animator and processes all actions (like movement, attack, etc). It can(and should be) customized according to your needs for example Player and AI actors has different Behavior-scrits since their actions and input sources are different.
Animator is standard Unity component, so all setups are pretty obvious:
- - You should have Avatar(created automatically) and Controller attached to it
- - Controller should have state-tree with parameter-controlled transitions (and parameters themselves) according to your needs (Better to have states and parameters directly related to possible actor actions, specified in ActorBehavior script)
- - Each state usually should have attached animation clip.
ActorAnimator setup is the most complicated. You should specify in Actions list all action types you want to control.
Each action in ActorAnimator consists from 3 main parts:
• General setups:
Preset type - Move, Attack, Jump, etc (to add new types you should update ActorActionType enum in ActorBehavior script) Automatic toggle - should be true if action dont require external input and can be called automatically in state-tree (for example Push-state will be called automatically if there is pushable object in front of player) TriggeredManually toggle - should be true if action should be called manually from the code (by using PerformActorAnimation function)
• Animator event – describes animator Controller parameter related to action
• Activatable – Optional list of things those can be activated during the action
Forced - toggle should be true if things should be always activated when action triggered. You canalso activate things by setting Events (in related Animation-clip) those will call ActivateFX function with action name as parameter.
ActorBehavior setups are really related on used.
Weapon system is much more clear and consists from next components:
- WeaponManager, that handles all weapons
- Weapon, that performing attack itself
- DamageableObject – optional script to handle damage receiving, wrecking etc
All details of their properties you can read as comments in related script, here is just a brief overview:
customEmitter - Bullets and raycasts origin/direction mountPoint - Mount-point for all weapons origins (usually its just a link to some empty object) animatorParameter - Name of Mecanim parameterthat controls SwitchWeapon state weapons - List of weapons prefabs to be used
• Attack() – shoot from current weapon
• RefilAmmo(weaponId) – add ammo(amount specified in ammoInPack property of the Weapon) to weapon with id weaponId in weapons list
• AddWeapon(newWeapon) - Create new weapon newWeapon from prefab and add it to weapons list
ammoInPack - Amount of ammo in ammo-pack (used for refilling) raycastDistance - Max effective distance of Raycasted Weapon projectiles - pool of projectile prefabs for Projectile Weapon
Note: Manual are going to be improved and extended, so please don't forget to check for updates.