orient(to:in:offset:)
Creates a constraint that forces a node to rotate to face a point in another node’s coordinate system.
Declaration
class func orient(to point: CGPoint, in node: SKNode, offset radians: SKRange) -> SelfParameters
- point:
A point in the
nodeparameter’s coordinate system. - node:
The node whose coordinate system the point is specified in.
- radians:
An offset that is added to the Zrotation value after it is calculated.
Return Value
A new constraint.
Discussion
Each time when constraints are applied, a new angle is calculated so that a line projected at this angle would point at the target point. This angle is added to the values specified in the radians property to create a new range. Finally, the node’s zRotation value is clamped to fit inside this range.