Skip to main content
Participant
September 24, 2021
Question

Looking to restrict the values in a Duik joystick

  • September 24, 2021
  • 1 reply
  • 196 views

Let me try to explain what I am doing

I want to have a hand-drawn animated head that I can control with a Duik joystick.

my idea is to create a 99-frame animation of the head rotating

the frame number would indicate the position of the head

the tens place would indicate the Y position and the ones place would indicate the X position

for example, 00 would be looking up and to the left and 99 would be looking down and to the right

 

I have it all rigged up with one problem

to make the math work out, I had to divide the Duik control output by 10 instead of 9

that means that the top right is 10 instead of 09

I think I just need a good way to restrict the output of the duik joystick so it doesn't go over 9 on the X axis and doesn't go over 90 on the Y axis. I've tried to do this several ways and it hasn't really worked out

 

Here's what the expression I'm working with looks like:

 

xnine=((thisComp.layer("C | Slider 2").effect("Slider")("X Value")+100)/2)/10; ynine=((thisComp.layer("C | Slider 2").effect("Slider")("Y Value")+100)/2)/10; xnines=Math.floor(xnine); ynines=Math.floor(ynine)*10; value=(xnines+ynines);

This topic has been closed for replies.

1 reply

Meng Zhiqun
Inspiring
November 1, 2021

You can try something like

if(x > 9){

 x = 9;

}

 

And this will just limit it to the max number of 9.