-
Limiting a random distance between points…
Can anyone please tell me why this expression doesn’t work?
I’m changing a random position every keyframe but I want to change to be limited to a minimum from the last point it was.nearestKeyIndex = thisProperty.nearestKey(time).index; previousKeyTime = thisProperty.key(nearestKeyIndex-1).time; seedRandom(nearestKeyIndex,true); x=random(200,1650); y=random(150,650); nearestKeyPoint = [x,y]; previousKeyPoint = thisProperty.valueAtTime(previousKeyTime); delta = length(nearestKeyPoint, previousKeyPoint); if (delta <100){ newPoint = nearestKeyPoint +[200,200]; newPoint; }else{ nearestKeyPoint; }