Using Xcode 12.5.1 and getting uncaught exception when trying to add child to the scene. Attached screenshot shows the code being used and output containing the prints data and the error. Anyone any ideas for me.
xcode 12.5.1 SpriteKit scene addchild fails reason already present
Is this something to do with what I am seeing in the scene. I wanted to attach a screenshot here to show the scene where the only items appearing in the scene inventory panel are the ground elements textures I drag from the asset library. There is no inventory of the tiles that have been used as shown in the graphics and that are editable after I double click the Tile Map Node. Is there anywhere I can see those? Also is the exception to do with the contents of the Tile Map Node itself? And how do I add a screenshot in a comment?
I have tried using an empty SpriteKitScene file and get same crash.
You can't add screenshots to comments.
The exception is saying that you are trying to add a physics body that already exists.
Does worldLayer
have any physics bodies in it when you add the child to it?
Do levelNode
and mapNode
have physics bodies?
Did you add any physics bodies to anything in your .sks
file? Do you have any code that creates physics bodies? If so, show the code as text, not as a screenshot. Code in a screenshot is hard to read.
Can you add children without crashing if the SpriteKit nodes have no physics bodies?
I found a work round. I set the mapNode PhysicsBody to nil before the add child. I have no idea where the PhysicsBody was set in the first place.