title: SpriteKit Networking Physics (Various Devices)
body: <p>I am working on a SpriteKit Game, that is networkable.  The problem I am having is that the physics vary on different devices and screen sizes., iPhone 5s, iPhone 6+, iPad Mini 2 Retina, and iPad 2, and MBP 17, and Air 11.</p>
  
  <p>The Players Play on a scene that is defined by this: self an SKScene, gameScene.m.</p>
  
  <p>For various reasons I made the gameScene.sks size 414x414 and createSceneContents using:</p>
  
  <pre><code>self.scaleMode = SKSceneScaleModeAspectFit;
  self.anchorPoint = CGPointMake(0.5,0.5);
  self.size = CGSizeMake(self.size.width*4, self.size.height*4);
  </code></pre>
  
  <p>I do the *4 because I am going to add zooming up to 1x 2x 4x.</p>
  
  <p>The beginning basics are two creatures that face off.
  I set both of their mass and density using:</p>
  
  <pre><code>char.physicsBody.density = 1.0;
  char.physicsBody.mass = 1.0;
  </code></pre>
  
  <p>I read changing them would fix different device/screen issues (false).</p>
  
  <p>When one is moving at the other I get mixed results when they collide.
  On the Mac when ramming the other the (iOS) creature the Mac creature gets stopped and can't budge the other.  The iOS char can ram the Mac creature and pushes him all around.</p>
  
  <p>I went in and changed the mass and density, based on:</p>
  
  <p>The scene takes up a square in the middle of the device so the bounds width is the width of the devices.  What is the golden number I need to put in here to make the iOS devices equal to the Mac devices.</p>
  
  <pre><code>// CGFloat result = [[UIScreen mainScreen] bounds].size.width //maybe later :)
  CGFloat ratio = 414/3000;
  
  char.physicsBody.density = 1.0*ratio;
  char.physicsBody.mass = 1.0*ratio;
  </code></pre>
  
  <p>This is just the basic starting point I began with.  The reason is I believe that that SpriteKit is making the objects proportional from screen to screen (bounds to bounds, devices to device).  But it's mainly Mac to iOS that is way off.  Mac to Mac is even in a head butt competition, I don't need to change the mass/density.</p>
  
  <p>The code is in my Xcode.project file and they share the source code, and compile from them.</p>
  
  <p>this block is used to go back and forth:</p>
  
  <pre><code>#ifdef IOS_BLOCK
      CGFloat ratio1 = (414.0/3000);
      CGFloat ratio2 = 1;
      _playerChar.physicsBody.mass = _playerChar.physicsBody.mass*ratio1;
      _playerChar.mainThrust = 160*ratio1;
      _playerChar.reverseThrust = 80*ratio1;
      _playerChar.lateralThrust = 0.4*ratio1;
  
      _opposeChar.physicsBody.mass = _opposeChar.physicsBody.mass*ratio2;
      _opposeChar.mainThrust = 160*ratio2;
      _opposeChar.reverseThrust = 80*ratio2;
      _opposeChar.lateralThrust = 0.4*ratio2;
  #else
      CGFloat ratio1 = 1;
      CGFloat ratio2 = (414.0/3000);
      _playerChar.physicsBody.mass = _playerChar.physicsBody.mass*ratio1;
      _playerChar.mainThrust = 160*ratio1;
      _playerChar.reverseThrust = 80*ratio1;
      _playerChar.lateralThrust = 0.4*ratio1;
  
      _opposeChar.physicsBody.mass = _opposeChar.physicsBody.mass*ratio2;
      _opposeChar.mainThrust = 160*ratio2;
      _opposeChar.reverseThrust = 80*ratio2;
      _opposeChar.lateralThrust = 0.4*ratio2;
  #endif
  </code></pre>
  
  <p>NOTE: I change it up in Mac vs Mac or iOS vs iOS to 1:1</p>
  
  <p>This value of 3000 seems to hold things at bay in head butt competitions using joystick vs keyboard vs UIButtons etc.</p>
  
  <p>But my question is what is this ratio's "weight" based on? 414/3000  I mean it could be 500/3000, 1/6 and that would make things fairly close too.</p>
  
  <p>But what is the need for the ratio and why do iOS vs iOS and Mac vs Mac work when 1:1, when iOS to Mac is 6:1? and I have to divide by the ratio.</p>
  
  <p>I was hoping to get everything EQUALIZED on all devices using SpriteKit.
  btw the Sprite Sizes are:
  102/204/306 (iOS)
  and
  120/240 (Mac)
  Thanks ahead for any help.</p>