• Studio

  • Bots

  • Web API

  • Designer Resources

  • Host Resources

  • API

    Datatypes

    Edit

    Vector2

    Represents a 2D vector for positions, velocities, and directions.

    Properties

    The normalized version of the Vector2.

    magnitude

    number

    The length of the Vector2.

    The square of the Vector2's magnitude.

    x

    number

    The x-component of the Vector2.

    y

    number

    The y-component of the Vector2.

    A Vector2 with both components set to zero.

    A Vector2 with both components set to one.

    A Vector2 pointing upwards.

    A Vector2 pointing downwards.

    A Vector2 pointing to the left.

    A Vector2 pointing to the right.

    A Vector2 with both components at positive infinity.

    A Vector2 with both components at negative infinity.

    kEpsilon

    number

    A very small positive number greater than zero.

    A small positive number for Vector2 computations.

    Methods

    Sets the x and y components of the Vector2.

    Parameters

    newX

    number

    New 'x' component.

    newY

    number

    New 'y' component.

    Returns

    void

    Scales the Vector2 by another's components.

    Parameters

    scale
    Vector2

    Vector2 to scale by.

    Returns

    void

    Converts Vector2 to a direction vector of length 1.

    Returns

    void

    The square of the Vector2's magnitude.

    Returns

    number

    Linearly interpolates between two Vector2's.

    Parameters

    First Vector2.

    Second Vector2.

    t

    number

    Interpolation factor.

    Returns

    Linearly interpolates between two Vector2's without clamping 't'.

    Parameters

    Starting Vector2.

    Ending Vector2.

    t

    number

    Interpolation factor.

    Returns

    Moves a Vector2 towards another Vector2 within a maximum distance.

    Parameters

    current
    Vector2

    Current Vector2.

    target
    Vector2

    Target Vector2.

    maxDistanceDelta

    number

    Maximum movement distance.

    Returns

    Multiplies two Vector2's component-wise.

    Parameters

    First Vector2.

    Second Vector2.

    Returns

    Reflects a Vector2 off a surface Vector2.

    Parameters

    inDirection
    Vector2

    Direction of incoming Vector2.

    Returns

    Checks if two Vector2's are not equal by comparing components.

    Negates the x and y components of a Vector2.

    Transforms a Vector2 into a unit vector, maintaining direction.

    PocketWorlds Icon

    © 2024 Pocket Worlds. All rights reserved.