• Studio

  • Studio API

  • Bots

  • Web API

  • Designer Resources

  • Host Resources

  • Ray

    Represents a line in 3D space extending indefinitely from a source point (origin) in a specified direction. It is utilized extensively for ray casting and collision detection.

    Properties

    Represents the starting point of the ray in 3D space.

    local origin = Vector3.new(0, 0, 0)
    local direction = Vector3.new(0, 0, 1)
    
    local ray = Ray.new(origin, direction)
    print(ray.origin) -- (0, 0, 0)
    

    Depicts the path along which the ray extends in 3D space. The direction vector is normalized to have a magnitude of 1.

    local origin = Vector3.new(0, 0, 0)
    local direction = Vector3.new(0, 0, 1)
    
    local ray = Ray.new(origin, direction)
    print(ray.direction) -- (0, 0, 1)
    

    Methods

    Retrieves a point along the ray at a specified distance from the origin. The distance is measured in the direction of the ray.

    local origin = Vector3.new(0, 0, 0)
    local direction = Vector3.new(0, 0, 1)
    
    local ray = Ray.new(origin, direction)
    local point = ray:GetPoint(5)
    
    print(point) -- (0, 0, 5)
    

    Parameters

    distance

    number

    The distance along the ray from the origin point.

    Returns

    Vector3

    Returns the point at the given distance along the ray.

    Updated 2 months ago

    PocketWorlds Icon

    © 2024 Pocket Worlds. All rights reserved.