Rolling a square: School Of Motion Response
Vložit
- čas přidán 28. 08. 2014
- School of motion just had a tutorial about rolling a square.
www.schoolofmotion.com/project...
Joey said that he had trouble getting the triganometry to work properly, so this is how to do it. be sure to go check out his tutorial, and also the rest of the 30 days of After Effects currently going on right now. pretty cool stuff.
here is the expression
rot=transform.rotation;
scl=transform.scale[0]/100;
w=(this.width/2)*scl;
r=(degreesToRadians(rot))*2;
t=transform.position;
slider=effect("Slider Control")("Slider");
[t[0]+w*rot/45,t[1]-(Math.abs(slider*Math.sin(r)))*scl];
My Tip Jar: goo.gl/rYpW42
⭐️ UNLIMITED STOCK DOWNLOADS
Access to over 600,000 ready-to-use After Effects Templates, Stock Footage, Fonts, Templates and more! cinemaspice.net/envato
to help support this channel.
Don't forget to share this video. You never know who among your friends is a closet After Effects user. Thanks.
Twitter
/ longlivemikey
Facebook:
/ thecinemaspice
If you need stock footage, photos and even After Effects templates. Go check out Envato Elements. cinemaspice.net/envato
to help support this channel.
Don't forget to share this video. You never know who among your friends is a closet After Effects user. Thanks.
Twitter
/ longlivemikey
Facebook:
/ thecinemaspice
You just made my day, what an eye-opener! Huge thanks!
Love your tutorials bro. Keep them coming!
This is pure gold!
Pretty Cool! Thanks for this!
really helpful, thank you
Great tut, I would like to see more expression tutorials. Great work. Love it!
+1
your so great sir
a new level of respect for you. I never knew you knew trig. You are the Mad Scientist... making your list...
i thought everyone learns trigonometry at school :)
Specular Some of us haven't been to school in quite some time :)
Cool tutorial... thx
太棒了,谢谢您的分享·~
With a bit more cleanup...
rotDeg = transform.rotation;
rotRad = degreesToRadians(rotDeg);
scaleFactor = transform.scale[0] / 100;
scaledWidth = this.width * scaleFactor;
slider = effect("Slider Control")("Slider");
hOffset = scaledWidth * rotDeg / 720;
vOffset = Math.abs(scaleFactor * slider * Math.sin(rotRad * 2));
add(transform.position, [hOffset, -vOffset]);
I am really impressed by the tutorial i didn't know that you are good a expression i hope that you make a serie of tuts about advanced expression because all tuts are for beginners i am sure that you'll get many more views :D
thanks this is really helpful! Would this be easily adapted for a hexagon shape?
that's pretty neat
Hi I get this error:
Error: couldn't turn rotation into numeric value.
Just go to File > Project Settings > Expressions > Legacy ExtendScript
If you replace "this.width" with "thisLayer.width" it will work without changing the Project Settings.
@@EmmaBay 🙏 this saved my life. Thank you
Thats awsome, can you please tell me how can i apply this expression to my square quickly? i just tried to paste the expression in my square position but it did not work.
Any idea how to tweak this for not perfectly square shapes?
Can you do one with a non round shape? something like an egg?
Man, that was magic. Sorcery, even.
My square isn’t moving I used the same code that was used at the end of the video and my vector square isn’t moving 😢
Brother can you tell how you compress this file so small in size?thanks
How would you do this with a triangle? Anyone have any advice? Thanks
can we use same expression for hexagon ??
great tut, thank you.
But in AE 2020
Error: couldn't turn rotation into numeric value.
File > Project Settings > Expressions > Legacy ExtendScript
@@DiogoMendesPinto Thank youuuuu!
How do you turn that into a preset?
+MikeyBorup there is one thing i have to ask. whenever it is rolling is there a way to make it roll straight on the corners?
+MikeyBorup also it looks like the corners move is there a way to fix this?
I think the value of the slider should be =(SQRT(2)/2-1/2)*H, with H the height of the layer :)
Any ideas on how you could apply this to a rectangle?
That would be much more difficult, but I think possible. you would need to calculated the scale difference between the long side vs the short side. and scale the trig equation. also you would need to know which side its on. that will be the hard part.
***** Actually, and I should have explained earlier, all I was trying to do was pivot a rectangle from lying on its long side to standing on its short end. I was able to do it (and I am new to expressions, so I apologize if I don't explain this well) with the anchor point centered on the short end and the rotation at 0, I divided the sR property:
sR=Math.abs(uS*Math.sin(r/2));
I did also have to mess with the width line, but that was messed up from the start (it seemed to be taking the width of the entire composition) I had to manually enter the width and divide it by 4 instead of 2:
w=(length(22.8)/4)*scl;
Which seems to have accomplished what I wanted, though it wouldn't work past 90 degrees.
Can you not do the same thing just moving the anchor point?
not without a complex expression, (maybe trig is just as complex) you will need to move the anchor point to each corner as it rotates.
How can position properties be added to this method to recreate the bounce effect as shown in the school of motion tutorial. I can't figure out how to rig that as the position curves are way off the box object and the x position is tied into the rotation property which seems counter intuitive to me.
Hi Jonathan. I used the os cand version in the comments below to get my box to roll but I believe it should work with Mikey's tutorial version as well.
- Create a null object
- Parent your box layer to the null object. That means the null object can control your position and you can add the bounces with the y position in the null object layer. Hopefully that makes sense and it works for you.
Could you make a tutorial on how to roll an egg?
The Rolling Cube looks pretty good. But I still think Motion Graphics has ya beat w/ the real world bounce effect.
Mine gets a syntax error on line 8? Any Ideas??
What does the error say?
Also make sure there are semi-colons on all lines
+After Effects Tutorials w/ Mikey To continue this conversation from a year ago for him,
he's right. The expression in your description doesn't work because for
some reason when you copy/paste it from the CZcams page, there's a dash
in the middle of the word "Math" in the last line (which strangely
isn't actually visible in the description), but if you take the
dash out, everything works.
Ok. Thankyou.
wow.... I thought we can just move the rotate anchor point or something....
Dude. How did you round the square corners so easily??
OMG, just double click the rounded rectangle tool! THAT was worth the price of admission. I never knew that!
one of the mask shapes is a rounded square. I just selected that shape and double clicked on the square.
***** Figured that out moments after asking (that'll teach me). Thanks, Mike!
Hey Mikey, not sure if something has changed with the latest release of AE since you posted this but the expression returns an error - couldn't turn result into numeric value. Have followed all your steps so not sure what's causing the issue.
Try thisLayer.width/2 for the w variable :)
it doesn't work for me... when i copy and paste it from the desc it comes up with an error saying it couldn't turn result into numeric value
Yeah it's weird, this worked for me in previous versions of AE, but it looks like something changed that broke this expression.
Use the width value from rectangle path. w=content("Rectangle Path 1").size[0]/2
Same here ;/ Did you guys find what should we put as w? content("rectangle path") doesn't work for me ;c
File > Project Settings > Expressions > Legacy ExtendScript
@@dolcevita8360 Thank you!
Thanks Mikey it's a lot of fun learning from you.
I found another way to do it without trigo just by moving the anchorPoint and position I adapted an expression found on this thread on Creative Cow : forums.creativecow.net/thread/227/22936 (Dan Ebberts answer).
It works for square and rectangle you can change the solid width and height and/or the scale.
Put this on the anchorpoint property:
sclWidth=transform.scale.value[0]/100;
sclHeight=transform.scale.value[1]/100;
count = Math.floor(rotation / 90);
val = count % 4;
switch (val) {
case 0:
[width, height];
break;
case 1:
case -3:
[width, 0];
break;
case 2:
case -2:
[0, 0];
break;
case 3:
case -1:
[0, height];
break;
}
This on position:
sclWidth=transform.scale.value[0]/100;
sclHeight=transform.scale.value[1]/100;
val = Math.floor(rotation / 90);
a = Math.abs(val%2);
b = Math.floor(val/2);
value + [(a+b)*height*sclHeight+b*width*sclWidth,0];
Animate the rotation.
Enjoy
OS
Thank you so much, os cand!
I tried to apply the expression from the video description, but got the same error on line 8 as The Pixel Perfectionist. The good things about your expression are:
1. It's applied to only one layer - so you can create a preset to apply to other layers in other projects;
2. It follows the layer scale distortions - apply to squares and rectangles;
3. It actually works on my project!
But I'd still like to thank After Effects Tutorials w/ Mikey, since without this great tut I wouldn't have found the means to do it!
Cheers!
This is excellent! Thanks a lot
not working on my square, i applied exact same expressions from your comment
What does math work for in real life? Here is the answer
Its easier with Newton. ;)
Does Newton do square rolling? I knew it did wheels.