#Vector3 math between two points [Resolved]
1 messages · Page 1 of 1 (latest)
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)})`);
}
}