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

Set Anchor Point position via Slider

Explorer ,
Nov 15, 2021 Nov 15, 2021

Hey there! I am trying to create an mogrt where an anchor point value can be set to a pre-defined value based on a slider.

 

I have parented the layer I want to move to a null object and applied the following expression to my null, bu it is not working. What am I doing wrong?

 

// variables

var select = thisComp.layer("Null 3").effect("Slider Control")("Slider");

var x = thisComp.layer("Null 3").anchorPoint[0];

var y = thisComp.layer("Null 3").anchorPoint[1];

 

//calculations if (select == [1]) {y= "-800";} else {y = 0;}

 

// output //

[x,y]

 

 

TOPICS
Expressions , How to , Scripting
1.3K
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 1 Correct answer

Community Expert , Nov 16, 2021 Nov 16, 2021

There are several flaws in your thinking.

 

Let me start with the ease operator. You need to add some kind of timing to make an interpolation method work. The syntax is:

x = ease(t, tMin, tMax, value1, value2);

t is the time, tMin is the start time, tMax is the end time, value1 is the start value, value2 is the end value. You can define time as frames or seconds and use thisLayer.inPoint as the starting time.

 

Using a slider for 3 different states is also not a good idea. From the movie you upl

...
Translate
Explorer ,
Nov 15, 2021 Nov 15, 2021

Screen Shot 2021-11-15 at 3.11.23 PM.png

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
Contributor ,
Nov 15, 2021 Nov 15, 2021

You can create 2 sliders on the layer, 1 for each axis. Hope this helps.

var sX = effect("SliderX")("Slider");
var sY = effect("SliderY")("Slider");

value+[sX,sY];

 

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
Contributor ,
Nov 15, 2021 Nov 15, 2021

Here's a screenshot!
Screenshot 2021-11-16 at 12.08.55 PM.png

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
Explorer ,
Nov 16, 2021 Nov 16, 2021

Thanks mengopoo, can you show me how that would fit into my expression?  

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
Contributor ,
Nov 16, 2021 Nov 16, 2021

Before that, may I ask what did you want to achieve with calculations if (select == [1]) {y= "-800";} else {y = 0;} or as per your screenshot, the ease() function?

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
Explorer ,
Nov 16, 2021 Nov 16, 2021

I need to set the achor point to a specific location based on the slider position. 

 

Slider Position 0 - Anchor Point [0, 0]

Slider Position 1 - Anchor Point [0, -800]

Slider Position 2 - Anchor Point [0, 600]

etc.

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
Explorer ,
Nov 16, 2021 Nov 16, 2021

The ease function was included so that the move to the new postion would be smooth.

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
Explorer ,
Nov 16, 2021 Nov 16, 2021

I am setting up an internal motion graphic template that will allow the user to use the slider to select which button of a remote control will be zoomed in to and highlighted.

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 Expert ,
Nov 16, 2021 Nov 16, 2021

There are several flaws in your thinking.

 

Let me start with the ease operator. You need to add some kind of timing to make an interpolation method work. The syntax is:

x = ease(t, tMin, tMax, value1, value2);

t is the time, tMin is the start time, tMax is the end time, value1 is the start value, value2 is the end value. You can define time as frames or seconds and use thisLayer.inPoint as the starting time.

 

Using a slider for 3 different states is also not a good idea. From the movie you uploaded it looks like you want the graphic to move in, wait for a bit, then move out. If you need 3 different positions then the "if" statement should use a Dropdown Menu control and the expression should look like this:

ctrl = effect("Dropdown Menu Control")("Menu");
y = value[1];


if(ctrl == 1){
	x = 800; // first x position
}
if (ctrl == 2){
	x = 0; // second x position
}
if (ctrl == 3){
	x = -100; // third x position
}
else{
	x = value[0]; // if any other value keep original value for x
}

[x, y]

If you only have 3 menu positions in the Dropdown Menu then the else statement is not needed. I just included it to prevent expression errors.

 

When you want to include animation in a mogrt at the start or end of the graphic you usually use protected areas. You set up the comp to be longer than needed and then protect the first and last section. If you did that you could use the layer in point and out point to set the timing of the move in and move out and you would not need the dropdown menu control. If you want to keep the ability to animate inside Premiere Pro there are other techniques. 

 

To give you the entire setup for this kind of move I need a lot more information on the design requirements. From the uploaded video, I don't see any need for any expressions or expression controls. All you need to do is animate the position of the graphic and set protected regions.

 

I hope this helps. You should spend some time with the MOGRT documentation. 

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
Explorer ,
Nov 16, 2021 Nov 16, 2021

Thanks Rick! That filled in the gaps I needed filled. I was able to use that to get my template working!

 

Thank you!

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
Contributor ,
Nov 17, 2021 Nov 17, 2021
LATEST

Thank you for the wonderful explanation Rick. You beat me to it! 🙂

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