# Continuously spawn and delete nodes

**URL:** <https://forums.kodeco.com/t/continuously-spawn-and-delete-nodes/39796>\
**Category:** 3D iOS Games by Tutorials\
**Created:** [February 25, 2018, 11:28pm UTC](https://forums.kodeco.com/t/continuously-spawn-and-delete-nodes/39796 "2018-02-25T23:28:51Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![cocopuffs](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/cocopuffs/32/81494_2.png) [@cocopuffs](https://forums.kodeco.com/u/cocopuffs)\
**Post date:** [February 25, 2018, 11:28pm UTC](https://forums.kodeco.com/t/continuously-spawn-and-delete-nodes/39796/1 "2018-02-25T23:28:51Z")

</div>

I want to spawn a node every 5 seconds and then delete the node when it reaches a certain position.  
I have created code to this but I get a stutter effect.

I spawn a new node

> ```
> let spawnNode = SCNNode();
>     
> let spawnAction = SCNAction.run({ node in
> self.testEnemy();
> })
>    
> let delayAction = SCNAction.wait(duration: 5, withRange: 5);
>     
> spawnNode.runAction(SCNAction.repeatForever(SCNAction.sequence([delayAction, spawnAction])));
>     
> self.rootNode.addChildNode(spawnNode);
> 
> ```

The node that is created and added to the scene

> ```
> let carNode = carScene!.rootNode.childNode(withName: "enemy1", recursively: false)!.clone() as SCNNode
>     
> carNode.name = "Car"
> carNode.scale = SCNVector3(0.25, 0.25, 0.25);
> carNode.position = SCNVector3(x: 25, y: (self._Gplatform?.position.y)! + 0.5, z: self.ArrayOfGroundPositions())
>     
> self.rootNode.addChildNode(carNode)
>     
> let moveAction = SCNAction.move(by: SCNVector3(x: -50.0, y: 0.0, z: 0.0), duration: 5.0)
> let removeAction = SCNAction.run { node -> Void in
> node.removeFromParentNode()
> }
> carNode.runAction(SCNAction.sequence([moveAction, removeAction]))
> 
> ```

If anyone can guide me in the right direction It would be very helpful.
