#Vector3 math between two points [Resolved]

1 messages · Page 1 of 1 (latest)

real current
#

I have a item that, when used, marks a Vector3 point as the center of a area that buffs the player. I want to create a vector3 particle beam from the player to the point of origin. How would I do that?

meager bobcat
#

You can use linear equations to spawn particles between the two points

#
function spawnPointsOnLine(x1, y1, z1, x2, y2, z2, numPoints) {
    if (numPoints < 2) {
        console.error("Number of points must be at least 2.");
        return;
    }

    // Calculate points evenly spaced along the line
    for (let i = 0; i < numPoints; i++) {
        let t = i / (numPoints - 1); // Normalize t between 0 and 1
        let x = x1 + t * (x2 - x1);
        let y = y1 + t * (y2 - y1);
        let z = z1 + t * (z2 - z1);

        console.log(`Point ${i + 1}: (${x.toFixed(2)}, ${y.toFixed(2)}, ${z.toFixed(2)})`);
    }
}
real current
#

oh yeah I guess I could do that huh?

#

wow I

#

I might be special