Game Object: collisionMask

collisionMask
  • Get/set the group(s) the game object can collide with

Type:
  • integer
Values:
  • 1 = Collision group 1
     
  • 2 = Collision group 2
    • 3 = Collision groups 2 and 1
  • 4 = Collision group 3
    • 5 = Collision groups 3 and 1
       
    • 6 = Collision groups 3 and 2
       
    • 7 = Collision groups 3 and 2 and 1
  • 8 = Collision group 4
    • 9 = Collision group 4 and 1
       
    • 10 = Collision group 4 and 2
       
    • 11 = Collision group 4 and 2 and 1
       
    • 12 = Collision group 4 and 3
       
    • 13 = Collision group 4 and 3 and 1
       
    • 14 = Collision group 4 and 3 and 2
       
    • 15 = Collision group 4 and 3 and 2 and 1
  • 16 = Collision group 5
    • etc
  • 32 = Collision group 6
    • etc
  • 64 = Collision group 7
    • etc
  • 128 = Collision group 8
    • etc
  • 256 = Collision group 9
    • etc
  • 512 = Collision group 10
    • etc
  • 1024 = Collision group 11
    • etc
  • 2048 = Collision group 12
    • etc
  • 4096 = Collision group 13
    • etc
  • 8192 = Collision group 14
    • etc
  • 16384 = Collision group 15
    • etc
  • 32768 = Collision group 16
    • etc
Collision Mask setting Blender 3D
  • Properties menu >> Physics >> Collision Bounds >> Collision Mask
Sample Code

################## get the collision group(s) the game object can collide with
  
# import bge
import bge

# get controller
cont = bge.logic.getCurrentController()

# get object that controller is attached to
obj = cont.owner

# get collision mask
collision_mask = obj.collisionMask

Sample Code

################## set the collision group(s) the game object can collide with
  
# import bge
import bge

# get controller
cont = bge.logic.getCurrentController()

# get object that controller is attached to
obj = cont.owner

# set collision mask
obj.collisionMask = 2