My question is pretty simple.
How to make an object copy rotation of another object with same speed but only every second circle. I know I can animate that using keyframes, but I need to have in constraint.
Blender Stack Exchange is a question and answer site for people who use Blender to create 3D graphics, animations, or games. It only takes a minute to sign up.
Sign up to join this communityMy question is pretty simple.
How to make an object copy rotation of another object with same speed but only every second circle. I know I can animate that using keyframes, but I need to have in constraint.
You could add a scripted driver to the desired rotation axis of the object with the intermittent rotation, using the following expresion:
var*(int((var/(2.0*pi))%2))
where the variable var
, (or whatever you want to call it) refers to the relevant rotation (X,Y,or Z) of the driving object.
Here, the Z rotation of the triangle is being driven by the expression, in which var
refers to the the Z rotation of the square.
EDIT in response to your comment:
We can make the expression a little more general by implicitly casting True and False to 1 and 0:
var*(int((var/(2.0*pi))%3)==1)
In this version, the number where the 3
is determines the number of turns in the cycle, and the number where the 1
is says which of the turns to follow, with 0 as the last, counting back. So this example would make the driven object follow the driver on the second of every three turns.
So, in order to have alternating rotations, in the example below, the green triangle uses:
var*(int((var/(2.0*pi))%2)==1)
..and the yellow triangle uses:
var*(int((var/(2.0*pi))%2)==0)
Any more than this - say, "the second and fifth out of every seven".. and it would probably be tidier to write a little function, and add it to the driver_namespace
.
var * (var // twopi)
Mod is handy for mapping eg mapping on 0, 1 for offset on an orbit div //
wil give you the whole number that you are calculating with int-divide-modulus combo
$\endgroup$
Sep 29, 2018 at 20:13
var if 1.0 <= (var // twopi) % 5 <= 2.0 else 0
Ternary op can be nested.
$\endgroup$
Sep 30, 2018 at 3:06