Skip to main content
New Participant
September 28, 2021
Question

Help with Checkbox expression transforming position of Layer

  • September 28, 2021
  • 1 reply
  • 141 views

Hi I need some help with this expression, I keep getting an error saying expression must be a result of dimension 2 not 1.

 

This is the current expression

 

x = transform.position[1];// current location of object x axis

y = transform.position[1];// current location of object in y axis

x1 = 1 ;

Y1 = 1 ;

cb = effect("1-1")("Checkbox") ;

if (cb ==1) {

{x1,Y1};

} else {[x,y];}

This topic has been closed for replies.

1 reply

Community Expert
September 28, 2021

You have defined both x and y as the y value of position in the first two lines. 

 

The if statement has x1 and Y1 in {} and they should be in [];

 

If I wanted the checkbox to move the layer from its current X, Y position to 1, 1 this is how I would write it.

 

 

cb = effect("1-1")("Checkbox");
if (cb == 1) {
    [1, 1];
} 
else {
    position;
}

 

 

If you want to define variables for everything I would write it like this:

 

 

pos = position;
x1 = 1 ;
y1 = 1 ;
cb = effect("1-1")("Checkbox");
if (cb == 1) {
     [x1, y1];
} 
else{
     position;
}