protected void PerformEnemyDieWithExplosion(SCNNode enemy, SCNVector3 direction) { var explositionScene = SCNScene.FromFile("art.scnassets/enemy/enemy_explosion.scn"); if (explositionScene != null) { SCNTransaction.Begin(); SCNTransaction.AnimationDuration = 0.4f; SCNTransaction.AnimationTimingFunction = CAMediaTimingFunction.FromName(CAMediaTimingFunction.EaseOut); SCNTransaction.SetCompletionBlock(() => { explositionScene.RootNode.EnumerateHierarchy((SCNNode node, out bool stop) => { stop = false; if (node.ParticleSystems != null) { foreach (var particle in node.ParticleSystems) { enemy.AddParticleSystem(particle); } } }); // Hide if (enemy.ChildNodes.Length > 0) { enemy.ChildNodes[0].Opacity = 0f; } }); direction.Y = 0; enemy.RemoveAllAnimations(); enemy.EulerAngles = new SCNVector3(enemy.EulerAngles.X, enemy.EulerAngles.X + (float)Math.PI * 4.0f, enemy.EulerAngles.Z); enemy.WorldPosition += SCNVector3.Normalize(direction) * 1.5f; this.PositionAgentFromNode(); SCNTransaction.Commit(); } else { Console.WriteLine("Missing enemy_explosion.scn"); } }