Reputation: 177
In my game, I add a new a tempLeftBox (an SCNNode with an SCNBox geometry, and an SCNMaterial) every 5 seconds or so along a straight path. The tempLeftBox has its own geometry and its own material. For each tempLeftBox that is added, the color of the box should be random. This random color should ONLY affect that ONE box that was just added. Not all of the boxes that are going to be added or have been added already. How should I go about doing this? Swift, SceneKit
Upvotes: 0
Views: 93
Reputation: 6278
I assume you're instantiating instances of tempLeftBox class...
Each instance you create, of your tempLeftBox, is unique. It's a reference type, meaning you can have many references to it, but each instance is utterly unique. Each time you make a box, create a reference to it, and set the materials to the qualities you want, and it should be unique. ie not affect your other instances.
Upvotes: 0