← Back to particle
Easing Points to a Target Using VEX (The Push/Pull Setup)
11 Aug 26 (1mo ago)
Let's say you have a setup where particles or objects are actively spreading outward, and you need a way to snap them back. You want a cyclical effect: they explode out, get reeled back into the center, spread out again, and repeat.
To handle that "pull back" phase without the points violently overshooting the center and jittering, VEX is the easiest way to handle the math.
Here is a snippet for the pop wrangle that calculates the distance to a target (0,0,0) and applies an automatic braking system so they ease into the center perfectly.
// 1. Define the target center
vector target = set(0, 0, 0);
// 2. Calculate direction and distance vectors
vector dir = target - @P;
float dist = length(dir);
vector dir_norm = normalize(dir);
// 3. Control parameters
float max_speed = 6.0; // The top speed your spheres will travel
float stop_dist = 0.1; // Distance from center where they stop moving
// 4. Update the velocity directly
if (dist > stop_dist) {
// Ramp down speed smoothly as they get closer to 0,0,0
float speed = min(max_speed, dist * 3.0);
@v = dir_norm * speed;
} else {
// Lock them down once they hit the target zone
@v = set(0, 0, 0);
}