added collision detection with obstacle layer