Copy link to clipboard
Copied
I'm following the steps from this tutorial Use The Force! Create a Star Wars Ship Flying Through Asteroids in After Effects (PART 1/2) - YouTub...
Once I get to 2:44 in the YouTube tutorial I start running into issues. I'm copying the expression word for word, but an error code comes up. I've attached an image so you can have a look at what I'm dealing with.
Let me know if I need to post anything more and please keep in mind I'm not yet proficient in After Effects.
EXPRESSION
l=this_comp.layer(“ship control”);
s=L.scale/100;
u=L.to_world_vec([s[0[,0,0]);
v=L.to_world_vec([0,s[1],0]);
w=L.to_world_vec([0,0,s[2]]);
sinb=clamp(w[0],-1,1);
b=Math.asin(sinb/this_comp.pixel_aspect);
cosb=Math.cos(b);
if(Math.abs(cosb)>.0005){
c=-Math.atan2(v[0],u[0]);
a=-Math.atan2(w[1],w[2]);
}else{
a= Math.atan2(u[1].v[1]);
c=0;
}
[radians_to_degrees(a),radians_to_degrees(b),radians_to_degrees(c)]
ERROR CODE
After Effects warning: Expression Disabled
Error at line 1 in property 'Orientation' of layer 2 ('ship control parent') in comp
'main v3'.
expression result must be of dimension 3, not 1
IMAGE
There were quite a few typos. Try it this way:
L=thisComp.layer("ship control");
s=L.scale/100;
u=L.toWorldVec([s[0],0,0]);
v=L.toWorldVec([0,s[1],0]);
w=L.toWorldVec([0,0,s[2]]);
sinb=clamp(w[0],-1,1);
b=Math.asin(sinb/thisComp.pixelAspect);
cosb=Math.cos(b);
if(Math.abs(cosb)>.0005){
c=-Math.atan2(v[0],u[0]);
a=-Math.atan2(w[1],w[2]);
}else{
a= Math.atan2(u[1],v[1]);
c=0;
}
[radiansToDegrees(a),radiansToDegrees(b),radiansToDegrees(c)]
Dan
Copy link to clipboard
Copied
There were quite a few typos. Try it this way:
L=thisComp.layer("ship control");
s=L.scale/100;
u=L.toWorldVec([s[0],0,0]);
v=L.toWorldVec([0,s[1],0]);
w=L.toWorldVec([0,0,s[2]]);
sinb=clamp(w[0],-1,1);
b=Math.asin(sinb/thisComp.pixelAspect);
cosb=Math.cos(b);
if(Math.abs(cosb)>.0005){
c=-Math.atan2(v[0],u[0]);
a=-Math.atan2(w[1],w[2]);
}else{
a= Math.atan2(u[1],v[1]);
c=0;
}
[radiansToDegrees(a),radiansToDegrees(b),radiansToDegrees(c)]
Dan
Copy link to clipboard
Copied
Thank you so much, Dan. I'd say I'm embarrassed but I've been frustrated with this for so long I'm just glad it's over! I'll definitely be studying my mistakes and keep learning.
Copy link to clipboard
Copied
There are a bunch of errors that I see right off the top.
The first line should be L= thisComp.layer("ship control");
The 3rd, 4th, and 5th lines use to_world_vec and the syntax is wrong. It should be: toWorldVec
Everything in the brackets in those three lines is wrong. Every time you start an array using a square bracket you need to close it. Look closely ([s[0[,0,0]); includes three opening brackets and one closing. Each opening square bracket needs a closing bracket.
I don't see any reason for a function using pixel aspect and besides that, it is written wrong. It should say pixelAspect and not pixel_aspect.
That's as far as I got. The whole expression is nonsense. You could try and go through each line and compare the methods with the proper syntax using the Expression Language menu in the Timeline, but that would probably be a waste of time. In my humble opinion, any tutorial that uses complex expressions and does not include a way to copy and paste that data to your project is a waste of time. I watched a few minutes of the tutorial and some of the ideas are good, but the explanation of the technique is pretty lousy.
Copy link to clipboard
Copied
Thank you for your time, Rick. I'm definitely going to be studying and learning JavaScript, so hopefully, this is a good first lesson!
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more