5

I have implemented 3DTouch peek and pop actions in my game.

Essentially I have a MenuScene and a GameScene. In the MenuScene I have 2 CollectionViewControllers (world select and level select). I can use peek and pop from the world select menu to get a preview of the level select menu. Everything is working perfect however I have 1 problem.

When I use peek and pop in the MenuScene and then transition to GameScene to play my game the physics seems to be messed up. Apply impulse is very low so my player is only jumping about 1/5 the height he should.

Even increasing the impulse to adjust for this scenario is not working, the jump height always stays the same doesn't matter what value I use.

It also seems that applyForce, which I use with core motion to move my player, is more sluggish.

What's strange is that it only seems to affect jumping. My code for shooting, which also uses an impulse, is still working fine.

It almost feels like that the player is heavier when I used peek and pop in the menu scene but I cannot see anything that would indicate so.

If I do not use peek and pop in the MenuScene and just go to GameScene I do not have this problem, everything is behaving as usual.

Steps I have tried so far to no avail.

  1. Trying to unregister the preview delegate when I exit my MenuScene.

     unregisterForPreviewing(withContext: ...)
    
  2. Adding the preview delegate directly to the world menu CollectionViewController, instead of adding it the rootviewcontroller.

  3. Using console to print out my GameScene physics values to see if something is messed up.

Am I missing something? Why are peek and pop actions messing up SpriteKit physics?

double-beep
  • 5,031
  • 17
  • 33
  • 41
crashoverride777
  • 10,581
  • 2
  • 32
  • 56
  • Hi, I have the same problem that you have. In my case it doesn't work without UIPreviewActions as well. I found a workaround but did you find a real fix? Thanks I. Advance. – Lenny1357 Dec 31 '17 at 18:21
  • Hey. I did not find a fix yet unfortunately. I Pressung Apple had not fixed it yet. May I ask what your workaround is? – crashoverride777 Jan 01 '18 at 11:14
  • Sure, but it’s nothing special. So after my scene has been messed up I reload some sprites so that the scene is at least displayed correctly and in order to get the impulse working correctly (or at least close to correct) I have a global correctionFactor variable. – Lenny1357 Jan 01 '18 at 11:18
  • Thanks for that, I give it a try. I am just updating my games for iPhone X, so I might have another go and see if I can find another fix. I will let you know if I find something. Thanks again and happy new year – crashoverride777 Jan 01 '18 at 11:20
  • Faced the same issue: as soon as peek gesture fires - bodies of all nodes become smaller (while sprites stay of same size) and seems like forces become weaker or nodes' weight increased. Presence of preview actions doesn't affect this; @crashoverride777 may be you done something else that eliminated bug in your case? – Varrry Mar 02 '18 at 21:11
  • One more detail - I get this issue on iOS11 both device and simulator, but don't get on iOS10 simulator. – Varrry Mar 02 '18 at 21:35

0 Answers0