I'm trying to rotate a node by SCNAction
, but it rotates relative to parent’s coordinate space. Is it possible to rotate a node relative local's coordinate system?
Asked
Active
Viewed 906 times
4

Nikita Ermolenko
- 2,139
- 2
- 19
- 41
2 Answers
10
Sure. You can obtain parent's space coordinates for rotation axis with convertVector method.
For example, this action will do 180 degrees rotation around local x-axis:
SCNAction.rotate(by: .pi, around: node.convertVector(SCNVector3(1, 0, 0), to: node.parent), duration: TimeInterval(5))

AlexKorovyansky
- 4,873
- 5
- 37
- 48
0
Have you tried:
[node runAction:[SCNAction rotateByX:0 y:1 z:0 duration:5.0]]; //Rotates the node along the y axis for 5 seconds.

Alan
- 1,132
- 7
- 15