I am trying to use SCNParticleSystem as a "template" for others. I basically want the exact same properties, except for the color animation for the particles. Here is what I have so far:
if let node = self.findNodeWithName(nodeName), let copiedParticleSystem: SCNParticleSystem = particleSystemToCopy.copy() as? SCNParticleSystem, let colorController = copiedParticleSystem.propertyControllers?[SCNParticleSystem.ParticleProperty.color], let animation: CAKeyframeAnimation = colorController.animation as? CAKeyframeAnimation { guard animation.values?.count == animationColors.count else { return nil }
I copy not only SCNParticleSystem , but also SCNParticlePropertyController and CAKeyframeAnimation just to be safe. I found that I had to manually make these βdeepβ copies βmanuallyβ since .copy() on SCNParticleSystem does not copy the animation, etc.
When I turn on the copied particle system on node, it was added (by setting birthRate to a positive number), nothing happens.
I donβt think the problem is with the node, with which I added it, since I tried to add particleSystemToCopy to this node and enable this, and the original particle system will become visible in this case. This seems to indicate to me that node I added that the copied particle system was in order in terms of its geometry, rendering order, etc.
Something else might be worth mentioning: the scene is loaded from a .scn file and not created programmatically in code. Theoretically, this should not affect anything, but who knows ...
Any ideas on why this copied particle system does nothing when I turn it on?
source share