In an earlier post I asked about the right settings for initializing a SCNParticleEngine. With some hints from Zay
I managed to get both the SCNP and code paths to work – almost identically. Except that the SCNP path had the particles shrinking over time while the coding path did not.
Turns out that buried inside the SCNP file is a dictionary entry “Size” which is a SCNParticlePropertyController. Here’s the code from the debugger:
The gotcha is that when I open the SCNP file in the editor, I can see the stars being animated etc. But there is no sign of an Action or any affordance to open such an editor. Now, this may be related to the fact that the SCNP file is all about the PE parameters for initializing the PE. There is NOT an actual node or object on the stage. One thought is you need to have an editable action or Xcode won’t open the Action editor?
How this action got there or how I might edit it is not clear. I assume someone put it in the SCNP in an earlier version of Xcode. Then the Action was forgotten. Or something like that. It may simply be a bug/corrupted SCNP file.
2
Answers
As you mention this is Core Animation animation driving
SCNParticlePropertySize
. It is possible to configure it in the SceneKit scene editor via the Attributes inspector (not the Action editor).To be able to control the size of your particles over time (i.ex. let them shrink) using code only, you have to use a SCNPropertyController and a CAKeyframeAnimation like so:
and then you do:
with the same approach you can animate the particle colours in a changing sequence over time.