Skip to content

vector.lerp function / vector support in math.lerp #1936

@HappySunChild

Description

@HappySunChild

Currently there is no built-in lerp function for the native vector type. Instead we have to write out a function to handle this ourselves.

local function vectorLerp(a: vector, b: vector, alpha: number)
	return a + (b - a) * alpha
end

local start = vector.create(-3, 1, 4)
local finish = vector.create(1, 5, 9)

local intermediate = vectorLerp(start, finish, 0.5)

This works well enough I suppose, but it can easily become repetitive having to write this in every file that requires it.

I propose that either vector.lerp be added to the vector library, or math.lerp natively support vector types, as currently it can only support numbers.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions