Question about easing

Hi again!

Is there a way with this code to easing with constant speed?

float x;
float y;
float easing = 0.05;

void setup() {
  size(640, 360); 
  noStroke();  
}

void draw() { 
  background(51);

  float targetX = mouseX;
  float dx = targetX - x;
  x += dx * easing;

  float targetY = mouseY;
  float dy = targetY - y;
  y += dy * easing;

  ellipse(x, y, 66, 66);
}

thx!

Tagged:

Answers

  • What do you mean by easing with const. speed? The point of easing is not to have a constant speed.

  • ahh thx!

    i mean that a ball follows a ball with constant speed. with easing the ball gets slower when the distance gets closer. i want the same speed all the time.

  • edited December 2015

    giCentre has a utility for easing, check if that helps.

    Edit: So you need to remove easing instead?

    x += dx;
    y += dy;
    
Sign In or Register to comment.