3

I just set up a boundary for my game which seems to be working alright until it is really forced, as in I make my character run towards it for several seconds, and then my character will just go straight through. Any explanations for this and how I can fix it?

edit: here is the code for my boundary

    func createSceneContents() {
         self.backgroundColor = .black
         self.physicsBody = SKPhysicsBody(edgeLoopFrom: self.frame)
                }

    createSceneContents()
        ship.physicsBody = SKPhysicsBody(rectangleOf: ship.size)
        ship.physicsBody?.affectedByGravity = false
        ship.physicsBody?.isDynamic = true
        ship.name = "ship"
        ship.physicsBody?.categoryBitMask = PhysicsCategory.ship
        ship.physicsBody?.collisionBitMask = PhysicsCategory.ship
Eric Aya
  • 69,473
  • 35
  • 181
  • 253

1 Answers1

0

Try setting precise collision detection for your ship:

ship.physicsBody?.usesPreciseCollisionDetection = true

You also might consider adding a physics category to the boundary.

caffreyd
  • 1,151
  • 1
  • 17
  • 25