SceneKit particle template xcode 11

Looks like the particle system for scenekit is not available as a template anymore in xcode 11. I can only see the SpriteKit version. Is this by design or a mistake, or is there another way to create one?

Might want to let Xcode create for you.


This from the docs may explain why it's gone missing (emphasis mine) while still being supported (don't forget to add the SceneKit frwmework)...


Use the Xcode Particle System Editor to Experiment with Particle Systems

In most cases, you don’t need to configure a particle system directly in your app or game. Instead, you use Xcode to configure a particle system’s properties. As you change the behavior of the particle system, Xcode immediately provides an updated visual effect. When complete, Xcode archives the configured system into a file, which you can then include with your project’s bundle resources. Then, at runtime, your game uses this archive to instantiate a new particle system.


Using Xcode to create your particle systems has a few important advantages:

  • You can easily learn the capabilities of the particle system class.
  • You can experiment quickly with new particle effects and see the results immediately.
  • You separate the task of designing a particle effect from the programming task of using it. Your artists can work on new particle effects independent of your game code.
  • You can attach a particle system to a node in the Xcode scene editor to preview the particle system in your scene.


To load a particle system from a file you created with Xcode, use the

init(named:inDirectory:)
method.

Particle System : In .scn file, click "+" button in top right corner, you'll see it just between "Field" and "Action"

ViktorEvil, your solution is correct. The problem you're getting an error is that you are initializing the Trail.scn file inside createTrail(color:geometry:) which is called inside spawnShape() which is called inside renderer(_:updateAtTime:), which causes your console to print the following:
Code Block
[SceneKit] Error: Scene <SCNScene: 0x2803f5500> is modified within a rendering callback of another scene (<SCNScene: 0x2803e0000>). This is not allowed and may lead to crash

The solution to fix this is to initialize the SCNScene for the trail outside createTrail(color:geometry:).
I got the hint from this StackOverflow answer.

So you need to declare a new variable in GameViewController:
Code Block swift
var trailScene: SCNScene!

Then, create a function:
Code Block swift
func setupTrailScene() {
trailScene = SCNScene(named: "Trail.scn")!
}

Then call this function in viewDidLoad(). Then modify your createTrail(color:geometry:) to use the instance variable trailScene instead of declaring the constant inside:
Code Block swift
func createTrail(color: UIColor, geometry: SCNGeometry) -> SCNParticleSystem {
let node: SCNNode = (trailScene.rootNode.childNode(withName: "Trail", recursively: true)!)!
let particleSystem: SCNParticleSystem = (node.particleSystems?.first)!
particleSystem.particleColor = color
particleSystem.emitterShape = geometry
return particleSystem
}


I think this is the best workaround so far, which is to create a particle system node inside a .scn file and get the particle system from that node.
You can still create .scnp in new Xcode releases:
  • File menu -> New -> File... (cmd+n);

  • Select "SceneKit Scene File"; hit Next;

  • change the file name (Save As filed) from "SceneKit Scene.scn" to "SceneKit Scene.scnp"; hit Create.

You now have a 3d particles .scnp file which you can adjust in the editor (and finish the RayWenderlich Geometry Fighter project without any issues or workarounds).
SceneKit particle template xcode 11
 
 
Q