How to get the anchor point to the center of a line?

Scripting for After Effects

How to get the anchor point to the center of a line?

Postby AKASGaming on 07/6/2020, 2:28 pm

Here's a little backstory:
I'm trying to make this saber spin from the center while constantly having the anchor point between the two points (Core Start and Core End)

Image

I prefer having to run a code to do this but if there's another way please let me know!
Thanks in advanced!

PS: I'm using Videcopilot Saber
AKASGaming
 
Posts: 1
Joined: 07/6/2020, 2:24 pm
System Specs: MacOS High Sierra (10.13.6)
Processor: 2 GHz Intel Core 2 Duo
Graphics: NVIDIA GeForce 9400M 256 MB

Re: How to get the anchor point to the center of a line?

Postby JPT7505 on 07/9/2020, 6:16 pm

Precomp it
JPT7505
 
Posts: 935
Joined: 02/9/2011, 8:17 am
System Specs: CPU: Intel i7-7820X CPU @ 3.60GHz
RAM: 128gb

GPU: Quadro M6000
GPU RAM: 12288MB

Re: How to get the anchor point to the center of a line?

Postby hans123 on 07/29/2020, 10:27 am

Hello AKASGaming,

You have a Layer with the Saber-Effect.
On this Layer under 'Transform' use this expression:

X1 = effect("Saber")("Core Start")[0];
Y1 = effect("Saber")("Core Start")[1];
X2 = effect("Saber")("Core End")[0];
Y2 = effect("Saber")("Core End")[1];
Xmid = (X1+X2)/2;
Ymid = (Y1+Y2)/2;
[Xmid, Ymid];

for "Anchor Point' and 'Position'.

Please see my short video.

Hans
Attachments

[ Play Quicktime file ] Midpoint.mp4 [ 1.28 MiB | Viewed 122 times ]

hans123
 
Posts: 1145
Joined: 12/28/2012, 1:37 am
Location: Paris / France


Return to After Effects Expressions