Scenekit: Crash when Setting physicsBody to nil - ios

Can anyone help on this one:
Still coding on my game App in a tunnel cave, I installed moving walls within a not-moving frame.
The good thing is that I can move the walls within the parent nodes (the frames).
Bad thing is, I need to set a physicsBody physicsShape - for the frame a concavePolyhedron, while for the wall a boundingBox does the job.
Now, when I try to remove the walls, the scene crashes with a BAD_EXEC.
I tried a lot of different things to find out why, and as it turns out, the childNode walls seem to be the problem.
Because, even though it is possible to set the parent physicsBody to nil, the app crashes when I do the same thing with the childs (the walls). No matter if the nodes are hidden or not, and no SCNAction is attached.
I found a similar question, in which an answer was provided in C++, a command called ‚cleanUpChildrenAndRemove‘, but I am coding in Swift and there doesn‘t seem to be an analog.
I am pretty sure something is messed up, but I have no idea what it could be or how to straigthen it.
Does anyone have the same issue or know an answer?

Related

SceneKit objects not showing up in ARSCNView about 1 out of 100 times

I can't share much code because it's proprietary, but this is a bug that's been haunting me for awhile. We have SceneKit geometry added to the ARKit face node and displayed inside an ARSCNView. It works perfectly almost all of the time, but about 1 in 100 times, nothing shows up at all. The ARSession is running, and none of the parent nodes are set to hidden. Further, when I look at Debug Memory Graph function in Xcode, the geometry appears to be entirely visible there (and doesn't seem to be set to hidden). I can see all the nodes attached to the face node perfectly within the ARSCNView of the memory graph, but on the screen, nothing shows up. This has been an issue for multiple iOS versions, so it didn't just appear with a recent update.
Has anybody run into a similar problem, or does anybody have any ideas to look into? Is it an apple bug, or is there a timing issue I might not be aware of? It's been really hard to debug because of how infrequent it is, and I haven't found it discussed on any other forums (but point me in the right direction if there is a previous discussion). Thanks!
This is pretty common practice if AR tracking is poor for some reason.
I ran into a similar problem too. I think it's definitely a tracking error which arises due to the fault of the user of AR app. Sometimes, if you're using World Tracking Config in ARKit and track a surrounding environment offhandedly or if you are tracking under inappropriate conditions – you get a sloppy tracking data which results in situation when your World Grid/Axis may be unpredictably shifted aside and your model may fly away somewhere. If such a situation arises - look for your model somewhere nearby – maybe it’s behind you.
If you're using a gadget with a LiDAR, the aforementioned situation is almost impossible, but if you're using a gadget with no LiDAR you need thoroughly track your room. Also there must be good lighting conditions and high-contrast real-world objects with distinguishable non-repetitive textures.

Stage3D iOS Antialiasing on AIR 24

With AIR 24 release we are able to set anti aliasing on Stage3D now, but there are some issues with it. Can anybody help how to use it in right way without changing entire project code ?
The issue I have is that anti alias works great, and no more jagged edges, but there are rendering issues and I guess some texture normals are being inverted, also when using Occlusion Material there are some jagged material shadows...
Next thing I notice is when drawing Wireframe Globe with Lines Segments - the lines are visible on the globe all the time, no matter if you add some object in front or not.
So, intersecting line segments with other materials don't work at all, and lines are on the screen forever.
Please, help if you find any trick fixing the issues.
Thanks
Just to add some more information: the issue seems to happen when shareContext = true. Without Starling there is antialiasing and the lineSegments are rendered at the current depth. It would be interesting to see if it works with other sharedContext besides Starling to isolate the issue. If I find an answer I will come back and post it. It would be nice to get this working. Any idea the performance hit on mobile of having a second instance of away3d? Layering that way might be a dirty work around.
*****EDIT****
AntiAliasing on the line Segments only occurs with sharedContext. View3D class does not seem to have it's antiAlias value set anywhere and when I forced it to a value of 2, all hell broke loose.
Edit#2
Mesh appears above line segments, Sprite3D do not.

How do you get rid of <SKMetalLayer: 0x155851c90>: calling -display has no effect. printing in the log?

I have a SpriteKit game and whenever I run this on a device : calling -display has no effect. This makes all of the nodes zPositions messed up which is really annoying to fix. So I was wondering if there is any way to fix it or if I just have to deal with it.
Have you tried setting PrefersOpenGL=YES in Info.plist to enable OpenGL mode in SpriteKit? For certain things like custom shader performance, the new Metal mode for SpriteKit is half baked and not working properly.
I'm getting the same message, seems to be a bug. I haven't seen any adverse effects on my games. Are you sure you actually gave your sprites a zPosition? You cannot rely on SpriteKit doing it by itself because by default
skView.ignoresSiblingOrder
is set to true to improve performance. This means SpriteKit might ignore the order of how you are adding the sprites to the scene, hence you get different zPositions than you might expect.
Giving all your sprites a zPosition should solve your problem.

collision detection and creation in xcode class

I'm working on making a new app in xcode and have run into two problems that always seem to be a problem when I program large projects.
Basically, I want the user of this app to be able to input specifics like size, position, color, and possibly speed and/or direction.
These inputs will create a square of specific size, position, and color which will move around the screen and interact with other squares the user has created.
Now here are my problems:
First: I have absolutely no idea how to create something in code. I know I almost certainly have to do this in a class, but I've never figured out how to do this in a single programming language.
Second: Interaction between the squares. How do I detect collisions between the possibly dozens or hundreds of squares the user creates.
I'd really like to figure out how to do this, especially because I'm sure it'll be helpful in not only this, but many other future projects.
Thanks
I would recommend using sprite kit for the collision detection and creation of the squares. You'll probably want to subclass SKSpriteNode to define the properties for your squares.
https://developer.apple.com/library/ios/documentation/GraphicsAnimation/Conceptual/SpriteKit_PG/Introduction/Introduction.html

SpriteKit: Dynamically adding and removing jointed bodies

I've built a platformer (prototype) using SpriteKit and I have a question which I haven't seen answered anywhere, including official documentation.
Since I'm starting to get impaired frame rates, I decided to remove nodes and re-add them dynamically to my scene based on their distance (essentially if they are offscreen or on) from the player's location. This seems to work fine and I can get 60fps. But this doesn't work the case of bodies that are jointed (such as a rope bridge).
I'm seeing exceptions during removal. I've finally managed to fix this by walking each node.physicsBody's joints and removing those before removing the node itself. In restoring them, I originally though that nesting each bridge under a single SKNode was the answer but this doesn't help with the joints that are added to the SKPhysicsWorld. I've played with using mutable arrays to hold onto everything but haven't figured out how remove or reattach all the nodes as they are essentially a chain. My last thought it to try to subclass the joints so that I can mark which bridge they belong to and rebuild the entire bridge in one pass as any portion of it gets close to being onscreen.
There must be an easier way to remove and rehydrate nodes (with joints). I'm probably missing something obvious. Any ideas?

Resources