Copy link to clipboard
Copied
I was watching tutorial in youtube 'Stephen Zammit' and he gives this expression for approximate object movement affected by the null that renamed 'Effector' with slider control and 3D control point that also all renamed to the name accroding in the codes:
var p1 = thisLayer.transform.position;
var p2 = thisComp.layer("Effector").toWorld([0,0,0]);
var RadiusStrength = thisComp.layer("Effector").effect("Radius Strength")(1);
var Radius = thisComp.layer("Effector").effect("Radius")(1);
var MoveX = thisComp.layer("Effector").effect("Position XYZ")(1)[0];
var MoveY = thisComp.layer("Effector").effect("Position XYZ")(1)[1];
var MoveZ = thisComp.layer("Effector").effect("Position XYZ")(1)[2];
var d = length(p1, p2);
var x = linear(d, Radius, RadiusStrength, MoveX, 0);
var y = linear(d, Radius, RadiusStrength, MoveY, 0);
var z = linear(d, Radius, RadiusStrength, MoveZ, 0);
var xPos = p1[0] + x;
var yPos = p1[1] + y;
var zPos = p1[2] + z;
[xPos, yPos, zPos];
And i need to change the fist two lines to "toWorld([0,0,0]);" because it said that if the position object that i give this expression in parented to another object i need to change the slightly with 'toWorld', and i changed the fist 2 lines to something like this, just like how it should be:
var p1 = thisLayer.toWorld([0,0,0]);
var p2 = thisComp.layer("Effector").toWorld([0,0,0]);
it should've work just fine but in this case i don't know why it's change the position after apply this
thankk you for anyone who reply this issue i really don't know where the problem is, even after asking it with all the ai lol
Hard to say, but depending on where the anchor point for the layer is, this might be better for the first line:
var p1 = thisLayer.toWorld(anchorPoint);
by the way i found the overall fix also combined with gemini ai lol, heres the fixed version for anyone who might faces the same problem:
var p1 = thisLayer.toWorld(thisLayer.anchorPoint);
var p2 = thisComp.layer("Effector").toWorld([0,0,0]);
var RadiusStrength = thisComp.layer("Effector").effect("Radius Strength")(1);
var Radius = thisComp.layer("Effector").effect("Radius")(1);
var MoveX = thisComp.layer("Effector").effect("Position XYZ")(1)[0];
var MoveY = thisComp.layer("Effector").effect("Position
Copy link to clipboard
Copied
Hard to say, but depending on where the anchor point for the layer is, this might be better for the first line:
var p1 = thisLayer.toWorld(anchorPoint);
Copy link to clipboard
Copied
thankk you it's actually work
Copy link to clipboard
Copied
by the way i found the overall fix also combined with gemini ai lol, heres the fixed version for anyone who might faces the same problem:
var p1 = thisLayer.toWorld(thisLayer.anchorPoint);
var p2 = thisComp.layer("Effector").toWorld([0,0,0]);
var RadiusStrength = thisComp.layer("Effector").effect("Radius Strength")(1);
var Radius = thisComp.layer("Effector").effect("Radius")(1);
var MoveX = thisComp.layer("Effector").effect("Position XYZ")(1)[0];
var MoveY = thisComp.layer("Effector").effect("Position XYZ")(1)[1];
var MoveZ = thisComp.layer("Effector").effect("Position XYZ")(1)[2];
var d = length(p1, p2);
var x = linear(d, RadiusStrength, Radius, MoveX, 0);
var y = linear(d, RadiusStrength, Radius, MoveY, 0);
var z = linear(d, RadiusStrength, Radius, MoveZ, 0);
var finalWorldPos = [p1[0] + x, p1[1] + y, p1[2] + z];
// THE FIX : Convert the final World Position back to this Layer's Local Space
if (thisLayer.hasParent) {
thisLayer.parent.fromWorld(finalWorldPos);
} else {
finalWorldPos;
}
Find more inspiration, events, and resources on the new Adobe Community
Explore Now