# Collision Traversers¶

A CollisionTraverser object performs the actual work of checking all solid objects for collisions. Normally, you will create a single CollisionTraverser object and assign it to base.cTrav; this traverser will automatically be run every frame. It is also possible to create additional CollisionTraversers if you have unusual needs; for instance, to run a second pass over a subset of the geometry. If you create additional CollisionTraversers, you must run them yourself.

The CollisionTraverser maintains a list of the active objects in the world, sometimes called the “colliders” or “from objects”. The remaining collidable objects in the world that are not added to a CollisionTraverser are the “into objects”. Each of the “from objects” is tested for collisions with all other objects in the world, including the other from objects as well as the into objects.

Note that it is up to you to decide how to divide the world into “from objects” and “into objects”. Typically, the from objects are the moving objects in the scene, and the static objects like walls and floors are into objects, but the collision system does not require this; it is perfectly legitimate for a from object to remain completely still while an into object moves into it, and the collision will still be detected.

It is a good idea for performance reasons to minimize the number of from objects in a particular scene. For instance, the user’s avatar is typically a from object; in many cases, it may be the only from object required–all of the other objects in the scene, including the walls, floors, and other avatars, might be simply into objects. If your game involves bullets that need to test for collisions with the other avatars, you will need to make either the bullets or the other avatars be from objects, but probably not both.

In order to add a from object to the CollisionTraverser, you must first create a CollisionHandler that defines the action to take when the collision is detected; then you pass the NodePath for your from object, and its CollisionHandler, to addCollider.

traverser = CollisionTraverser('traverser name')
base.cTrav = traverser

collisionTraverser.showCollisions(render)