Layers and Tags
NeoFPS has a number of systems that require objects to be filtered using layers. The following is the layer set-up required by NeoFPS, along with an overview of some useful features for working with layers in code.
|PostProcessingVolumes||Trigger volumes used by the Unity post processing system to define override volumes.|
|EnvironmentRough||Low detail mesh and primitive colliders used for character motion and traversal.|
|EnvironmentDetail||High detail mesh and primitive colliders used for weapon impacts.|
|MovingPlatforms||Low detail mesh and primitive colliders used for character motion on moving platforms.|
|DynamicProps||Dynamic rigidbody props. Used for larger objects that could affect characters such as barrels.|
|CharacterControllers||Used for character controller root objects.|
|CharacterFirstPerson||Character geometry and objects visible from the first person view.|
|CharacterExternal||Character geometry and objects visible from the external views.|
|CharacterPhysics||Character body colliders, used for things like bullet impact detection.|
|CharacterPhysics||Character body colliders used for ragdolls, so set up to collide against the ground but not detail physics.|
|CharacterNonColliding||Used for objects that are tested against using Physics casts, but not the Unity collision system.|
|WieldablesFirstPerson||First person geometry and colliders for weapons and other wieldable objects.|
|WieldablesExternal||Geometry and colliders for weapons and other wieldable objects when seen from an external view.|
|TriggerZones||Trigger volumes that act on character triggers.|
|InteractiveObjects||Low detail trigger volumes used for detecting interactive objects.|
|DoorPhysics||Colliders for door objects.|
|SmallDynamicObjects||Small rigidbody objects that should not noticably affect characters. A character can push them around, but they can't really push a character.|
|Effects||A layer used for debris and particle effects.|
|AiVisibility||Low detail colliders used by AI for visibility checks.|
|AI||Used to tag AI characters.|
Layer Collision Matrix
The layer collision matrix is used to define which layers can interact with each other in the Unity physics system. Keeping a minimum of layers from colliding with each other is important to maintaining performance as well as for keeping interactions between different systems clean.
In the above example image, the green objects are character blockers on the CharacterRough and EnvironmentRough layers that are used for moving characters around the scene. The red objects are bullet blockers on the EnvironmentDetail layer that are used for bullet hits.
In code you can use the
PhysicsFilter type to define filters when performing physics operations. This also has a number of preset constants for aiding in writing code.
PhysicsFilter.LayerIndex contains the layer indices matching the layers as specified in the layers and tags settings.
PhysicsFilter.LayerFilter contains a number of preset physics filters matching the layers as specified in the layers and tags settings.
PhysicsFilter.Masks contains a number of filters for commonly used groups of layers as follows:
|BulletBlockers||Layers that bullet raycasts can hit.|
|CharacterBlockers||Layers that characters traverse. Includes larger props and platforms.|
|DynamicCharacterBlockers||Layers that characters traverse. Excludes static environment physics.|
|Interactable||Colliders attached to interactive objects, along with environment colliders that can block them from view.|
|SpawnBlockers||Any dynamic objects that can block spawn points.|
|ShowDecals||Objects that can accept decals.|
|AiVisibilityCheck||AI visibility markers and environmental colliders that can block them from view.|