Every frame, LookAtComponent rotates its SceneObject to face towards a target SceneObject.

// Switches through LookAt targets in a list on each tap
//@input Component.LookAtComponent lookAt
//@input SceneObject[] targets

var targetIndex = 0;

script.createEvent("TapEvent").bind(function(eventData)
{
if(script.targets.length > 0)
{
targetIndex = (targetIndex + 1) % script.targets.length;
script.lookAt.target = script.targets[targetIndex];
}
});
// Set aimVectors to [-Z Aim, Y Up]
// (Useful for aiming the camera since it faces towards -Z)
//@input Component.LookAtComponent lookAt
script.lookAt.aimVectors = LookAtComponent.AimVectors.NegativeZAimYUp;
interface LookAtComponent {
    aimVectors: LookAtComponent.AimVectors;
    enabled: boolean;
    lookAtMode: LookAtComponent.LookAtMode;
    offsetRotation: quat;
    sceneObject: SceneObject;
    target: SceneObject;
    uniqueIdentifier: string;
    worldUpVector: LookAtComponent.WorldUpVector;
    destroy(): void;
    getSceneObject(): SceneObject;
    getTransform(): Transform;
    getTypeName(): string;
    isOfType(type: string): boolean;
    isSame(other: ScriptObject): boolean;
}

Hierarchy (view full)

Properties

The "aim" and "up" vectors used when determining rotation. LookAtComponent will try to point the Aim axis of the SceneObject towards the target, while keeping the Up axis of the SceneObject pointing towards worldUpVector.

enabled: boolean

If disabled, the Component will stop enacting its behavior.

Controls the method of rotation being used.

offsetRotation: quat

Adds an additional rotation offset.

sceneObject: SceneObject
target: SceneObject

The SceneObject this LookAtComponent targets.

uniqueIdentifier: string

The vector to be considered the "up" vector when determining rotation.

Methods

  • Destroys the component.

    Returns void

  • Returns the name of this object's type.

    Returns string

  • Returns true if the object matches or derives from the passed in type.

    Parameters

    • type: string

    Returns boolean

  • Returns true if this object is the same as other. Useful for checking if two references point to the same thing.

    Parameters

    Returns boolean