If I have a function that spawns a cube right next to a previous cube whenever the user taps the screen and changes the color of the cubes as well, how can I make sure that each cube can become a random color and not the all the cubes become the same random color? I don't think I can use the same geometry for each cube because then it would inherit whatever material I originally gave to it. I want each cube that is spawned to select its own random color, not all the cubse select the same random color that it picks when tapping. I have a random color function, and it works. But if I spawn 5 cubes, and tap the screen, all 5 cubes become the same random color. But instead, I want each individual cube to be its own random color. I am using Swift, and SceneKit. Thanks for your help in advance!
Aucun commentaire:
Enregistrer un commentaire