-
Hitbox + generate a random value
Hello everyone, I’m trying something I thought would be simple, but isn’t quite working.
Basically:
- —I have a shape layer, and a null object on my scene. The null object’s position wiggles, and at times matches the position of the shape layer. I set up a hitbox to make this encounter as real as it can virtually be;
- —so when when the null object hits it, the shape layer’s position is affected. This works!
- —but I also have to generate a random value, between 3 and 12. The value has to be different every time the null object re-enters the shape’s hitbox (I mean: it can be the same value twice or thrice in a row of course, but has to vary most of the time). Here is the expression I wrote (“curseur” is “slider” in French):
var p1 = thisLayer.transform.position;
var p2 = thisComp.layer("Cible").transform.position;
var HitIn = thisComp.layer("Controller").effect("hitbox Inside")("Curseur");
var HitOut = thisComp.layer("Controller").effect("hitbox Outside")("Curseur");
var d = length(p1, p2);
if(d<HitOut){
seedRandom(1, true);
var r = Math.round(random(3, 12));
} else if(d>HitOut){
seedRandom(0, true);
var r = Math.round(random(3, 12));
}
rAny clue why this does not work?
Thank you in advance,
Simon