API ReferenceGE Extensionsflowgraphnodesmathquaternion
Look At (Flowgraph Node)
- **Node Name:** `Look At`
Overview
- Node Name:
Look At - Category:
simple - File:
extensions/flowgraph/nodes/math/quaternion/lookAt.lua
Computes the quaternion rotation needed to look from one position toward another.
Pin Schema
Input Pins
| Pin | Type | Description |
|---|---|---|
from | vec3 | The origin of the look-vector |
to | vec3 | The target of the look-vector |
up | vec3 | Up-vector (default {0,0,1}), hidden/hardcoded |
Output Pins
| Pin | Type | Description |
|---|---|---|
value | quat | The look-at rotation as a quaternion |
Internals
| Field | Purpose |
|---|---|
dirVec (local) | Reusable vec3 for the direction vector |
dirVecUp (local) | Reusable vec3 for the up vector |
rot (local) | Reusable quat for the result |
How It Works
- Both
fromandtomust be provided; the node exits early if either is nil. - The direction vector is computed:
dirVec = to - from. - The up vector defaults to
(0, 0, 1)unless overridden via theuppin. rot:setFromDir(dirVec, dirVecUp)computes the quaternion that faces along the direction.- The result is output as a table via
rot:toTable().
Lua Example
-- Point a camera at a vehicle:
-- from = camera position (vec3)
-- to = vehicle position (vec3)
-- value output = quaternion to set camera rotation
-- Custom up vector for banking:
-- up = {0.1, 0, 0.9} for a slight rollKey Dependencies
vec3,quat- vector/quaternion math primitivessetFromDir()- computes rotation from direction + up vectors_flowgraph_createNode()- standard flowgraph node registration
Additional Methods
C:init()
Initializes the node, setting up pins and default properties.
C:work()
Main work function called each frame/tick when the node is active.
See Also
- Direction (Flowgraph Node) - Related reference
- FlowGraph Guide - Guide