bw logo

Chapter 3. Using the SkeletonCollider

3.1. Creating the SkeletonCollider

Now that we have created our bounding boxes we need to create the SkeletonCollider for the object and make it interact with the box attachments. A new instance of the SkeletonCollider class needs be created and added to the entity's skeletonCollider property, we also need to add the BoxAttachments to the SkeletonCollider so it knows which boxes to use for targeting.

#Create the Skeleton Collider object
creature.skeletonCollider=BigWorld.SkeletonCollider()
#Add our colliders to it
creature.skeletonCollider.addCollider(headBox)
creature.skeletonCollider.addCollider(pelvisBox)

Note

It is important that the new SkeletonCollider object is assigned to the entity's skeletonCollider property as this is recognised by the targeting system.

3.2. Enabling skeleton checking

Now the only thing we need to do is to enable skeleton checking in the targeting system. This will mean that any entity that has a skeletonCollider attribute will use this for targeting rather than the model bounding box. This will need to be done from script whenever you want to enable skeleton targeting.

#enable skeleton checks
BigWorld.target.skeletonCheckEnabled=True

You should now only be able to target the creature entity when looking at its head or body.