2
$\begingroup$

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.

$\endgroup$
2
  • 2
    $\begingroup$ Do you mean rotate half as fast, or stop completely every other rotation? $\endgroup$
    – Robin Betts
    Sep 27, 2018 at 21:49
  • $\begingroup$ Stop completely every other rotation. $\endgroup$
    – Michal
    Sep 28, 2018 at 10:03

1 Answer 1

8
$\begingroup$

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.

enter image description here

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)

enter image description here

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.

$\endgroup$
12
  • $\begingroup$ That's what I was looking for. Thank you very much! $\endgroup$
    – Michal
    Sep 29, 2018 at 15:02
  • 1
    $\begingroup$ @Michal.. I've made an edit to cover this.. $\endgroup$
    – Robin Betts
    Sep 29, 2018 at 17:53
  • 1
    $\begingroup$ Consider div instead of mod in this case. ` 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$
    – batFINGER
    Sep 29, 2018 at 20:13
  • 1
    $\begingroup$ Sorry re confusion, was pointing out that revs or laps can be calculated using div not that mod and int were always avoidable. The ternary operator is another (often more) readable way eg var if 1.0 <= (var // twopi) % 5 <= 2.0 else 0 Ternary op can be nested. $\endgroup$
    – batFINGER
    Sep 30, 2018 at 3:06
  • 1
    $\begingroup$ As pointed out often its easier to make a method in the driver namespace to avoid the single line madness. Akin to print pages '[1, 3, 4-6]` Would like to see a subexpression in drivers akin to math surface to cut down long expressions.. . Mapping equation to 0 or 1 and driving a copy rotation constraint influence is another way that can be less complex equation wise. Is the square above slightly leading the triangle? 8UV's too man.. envious lol. $\endgroup$
    – batFINGER
    Sep 30, 2018 at 3:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .