2

How can I animate a change in color of an SCNNode? In SpriteKit I would just use the colorizeWithColor SKAction, but that is not an option in SceneKit. In SpriteKit, I would typically have a collision between two nodes. When the nodes collided one of the nodes changed colors simply by running the colorizeWithColor SKAction. What's the equivalent of this in SceneKit for an SCNNode?

Asdrubal
  • 2,421
  • 4
  • 29
  • 37
Tiptech
  • 177
  • 1
  • 17

1 Answers1

4

You can use the multiply property of your material to achieve a similar effect. You can set the fade length with SCNTransaction's animationDuration property.

SCNTransaction.begin()
SCNTransaction.animationDuration = yourFadeDuration
geometry?.firstMaterial?.multiply.contents = yourDesiredColor
SCNTransaction.commit()
andyvn22
  • 14,696
  • 1
  • 52
  • 74