Adding and removing collide masks


/ Published in: Python
Save to your folder(s)



Copy this code and paste it in your HTML
  1. def addCollideMask(np,mask):
  2. """Add mask to the NodePath's existing collide mask (do a binary OR of
  3. the two bitmasks)."""
  4. np.setCollideMask(np.getCollideMask() | mask)
  5.  
  6. def removeCollideMask(np,mask):
  7. """Remove mask from the NodePath's existing collide mask (all bits set
  8. to 1 in mask will be set to 0 in the NodePath's mask)."""
  9. # Need to copy mask first to avoid modifying it in place.
  10. copy = mask & BitMask32.allOn()
  11. copy.invertInPlace()
  12. np.setCollideMask(np.getCollideMask() & copy)

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.