Set Camera Rotation (Flowgraph Node)
- **Node Name:** `Set Camera Rotation`
Overview
- Node Name:
Set Camera Rotation - Category:
repeat_instant - File:
extensions/flowgraph/nodes/scene/camera/setCameraRotation.lua
Sets the free camera's rotation using a quaternion. Supports two modes: a hardcoded custom rotation or a dynamic rotation from an input pin. Preserves current camera position.
Pin Schema
Output Pins
| Pin | Type | Description |
|---|---|---|
value | quat | The rotation that was set |
Dynamic Input Pins (mode-dependent)
| Pin | Type | Description |
|---|---|---|
rot | quat | Rotation from pin (only in "from Pin" mode) |
Behavior
work()- Each frame:- Switches to free camera if needed.
- Reads rotation from input pin (if "from Pin" mode) or uses stored custom rotation.
- Calls
SetCamera()which usescore_camera.setPosRot()with current position and the new rotation. - Outputs the applied quaternion.
drawCustomProperties()- Editor UI with:- Mode dropdown:
customorfrom Pin - Rotation drag fields (4 floats for quaternion, in custom mode)
- "Set from camera" button to capture current camera rotation
- "Preview" button to apply the rotation
- Mode dropdown:
- Serialization - Saves/restores rotation and mode. Normalizes the quaternion on set.
Internals
self.rotation-quatstoring the target rotationself.mode-'custom'or'from Pin'SetCamera()- Applies rotation while preserving position viacore_camera.getPosition()
Key Dependencies
commands.isFreeCamera()/commands.setFreeCamera()- Free camera managementcore_camera.setPosRot(player, x, y, z, qx, qy, qz, qw)- Sets camera transformcore_camera.getPosition()- Gets current camera positioncore_camera.getQuat()- Gets current camera rotation (for editor capture)
How It Works
Mirror of Set Camera Position but for rotation. In custom mode, the quaternion is editable in the node editor. In from Pin mode, a dynamic input pin accepts quaternion data from other nodes. The rotation is normalized when set via the editor. Position is always preserved when updating rotation.
Example Usage
-- Static look direction: use custom mode, capture rotation from editor
-- Dynamic rotation: use from Pin mode, wire a quat from interpolation nodes
-- Combine with Set Camera Position for complete camera transform controlAdditional Methods
C:_onDeserialized(nodeData)
Called after the node is deserialized (loaded from file). Restores runtime state from saved data.
Parameters:
nodeData
C:_onSerialize(res)
Called when the node is serialized (saved to file). Returns data to persist.
Parameters:
res
C:drawMiddle(builder, style)
Custom ImGui drawing in the middle section of the node in the editor.
Parameters:
builderstyle
C:init()
Initializes the node, setting up pins and default properties.
See Also
- Camera Transform (Flowgraph Node) - Related reference
- Camera Look at Position (Flowgraph Node) - Related reference
- Camera Auto Circle (Flowgraph Node) - Related reference
- FlowGraph Guide - Guide