Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

toWorld([0,0,0]); expression make objects shifting to another place

Community Beginner ,
Jun 29, 2025 Jun 29, 2025

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
image.pngimage.png

TOPICS
Error or problem , Expressions
170
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 2 Correct answers

Community Expert , Jun 30, 2025 Jun 30, 2025

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);
Translate
Community Beginner , Jun 30, 2025 Jun 30, 2025

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

...
Translate
Community Expert ,
Jun 30, 2025 Jun 30, 2025

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);
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jun 30, 2025 Jun 30, 2025

thankk you it's actually work

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jun 30, 2025 Jun 30, 2025
LATEST

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;
}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines