title: Randomly generating two nodes
body: <p>I am creating a mobile application in Swift 3's SpriteKit. I am trying to create two rocks that a character has to dodge. I have the random generation working with -></p>
  
  <pre><code>func createTopRock(){
      var topRockChoice = [SKTexture(image: #imageLiteral(resourceName: "rockDown")), SKTexture(image: #imageLiteral(resourceName: "rockGrassDown")), SKTexture(image: #imageLiteral(resourceName: "rockSnowDown")), SKTexture(image: #imageLiteral(resourceName: "rockIceDown"))]
  
      let topRock = SKSpriteNode.init(texture: topRockChoice[mapChoice], size: CGSize(width: (self.scene?.size.width)! / 10,  height: (self.scene?.size.height)! / 2.2))
      topRock.zPosition = -9
      topRock.name = "TopRock"
      topRock.position = CGPoint(x: self.frame.width + topRock.size.width * 2, y: frame.maxY - topRock.frame.height / 2)
  
      topRock.physicsBody = SKPhysicsBody(texture: topRockChoice[mapChoice], size: CGSize(width: (self.scene?.size.width)! / 10,  height: (self.scene?.size.height)! / 2.2))
      topRock.physicsBody?.categoryBitMask = physicsCatagory.topRock
      topRock.physicsBody?.collisionBitMask = physicsCatagory.plane
      topRock.physicsBody?.contactTestBitMask = physicsCatagory.plane
      topRock.physicsBody?.affectedByGravity = false
      topRock.physicsBody?.isDynamic = false
  
      self.addChild(topRock)
  
      let randomNumTop = arc4random_uniform(3) + 3
  
      spawnDelayForeverTop = Timer.scheduledTimer(timeInterval: TimeInterval(randomNumTop), target: self, selector: #selector(self.createTopRock), userInfo: nil, repeats: false)
  }
  
  func createBtmRock(){
      var btmRockChoice = [SKTexture(image: #imageLiteral(resourceName: "rock")), SKTexture(image: #imageLiteral(resourceName: "rockGrass")), SKTexture(image: #imageLiteral(resourceName: "rockSnow")), SKTexture(image: #imageLiteral(resourceName: "rockIce"))]
  
      let btmRock = SKSpriteNode.init(texture: btmRockChoice[mapChoice], size: CGSize(width: (self.scene?.size.width)! / 10,  height: (self.scene?.size.height)! / 2.2))
      btmRock.zPosition = -9
      btmRock.position = CGPoint(x: self.frame.width, y: frame.minY + btmRock.frame.height / 2)
      btmRock.name = "BtmRock"
  
      btmRock.physicsBody = SKPhysicsBody(texture: btmRockChoice[mapChoice], size: CGSize(width: (self.scene?.size.width)! / 10,  height: (self.scene?.size.height)! / 2.2))
      btmRock.physicsBody?.categoryBitMask = physicsCatagory.topRock
      btmRock.physicsBody?.collisionBitMask = physicsCatagory.plane
      btmRock.physicsBody?.contactTestBitMask = physicsCatagory.plane
      btmRock.physicsBody?.affectedByGravity = false
      btmRock.physicsBody?.isDynamic = false
  
      self.addChild(btmRock)
  
      let randomNumBtm = arc4random_uniform(2) + 1
  
      spawnDelayForeverBtm = Timer.scheduledTimer(timeInterval: TimeInterval(randomNumBtm), target: self, selector: #selector(createBtmRock), userInfo: nil, repeats: false)
  }
  </code></pre>
  
  <p>As you can see from the code everything works. The one thing I do not want to do is have it like Flappy Bird and have the <code>btmRock</code> and <code>topRock</code> to have the same position, so to prevent that I have added the <code>timeIntervals</code> to be different. This works to an extent; but the player still runs into some rocks that are nearly impossible to go through.</p>
  
  <p><a href="https://i.stack.imgur.com/3qn3B.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3qn3B.png" alt="enter image description here"></a></p>
  
  <p>I feel like I am going about this wrong and I don't know how to fix this. I want them to be close enough sometimes to be hard but not nearly impossible. When I tried to implement a <code>bool</code> system to when a top rock is created and is within a certain distance don't create a bottom rock. What I ran into trying to do this is that I would never have a bottom rock after that occurred. Thanks in advance. </p>