1
$\begingroup$

I created a driver to move an edge as a constant size hypotenuse of an animated right angle triangle.

import bpy
import math as m

def rigthAngleTransform(rot, length):
    locY = length-(m.cos(rot)*length)-length
    return locY

bpy.app.driver_namespace["rigthAngleTransform"] = rigthAngleTransform

The representation of these values: enter image description here

This screenshot is not at the start frame! At the start frame the pivot is from "length" distance from the X axis and rot is 0d

Where rot is animated from 0d to 90d (the script uses radians!), while the pivot Y location coordinate is decreasing according to the following function:

locY = length-(cos(rot)*length)-length

The fun part it works perfectly as it should by math if I choose a frame with the mouse cursor. however if I play the animation or change the frames with the arrow keys it will deviate like this:

enter image description here

The end point at the x axis should not deviate from it

A good clue if I change the direction of the animation playback the direction of the deviation will be the opposite (hypotenuse will go under the x axis)

If my perception is correct, during animation the driver has a 1 frame latency.

Update:

My perception was correct I modified the script to use the z rotation value of the next frame, by adding 90/45d to the z rotation. Now it works perfectly during animation, if the interpolation is linear, and it will generate a deviation if I select a frame by clicking.

updated script:

import bpy
import math as m

def rigthAngleTransform(rot, length):
    locY = length-(m.cos(rot+m.radians(90/45))*length)-length
    return locY

bpy.app.driver_namespace["rigthAngleTransform"] = rigthAngleTransform
$\endgroup$
0
$\begingroup$

Well I found a very easy solution to the problem.

I use an empty proxy object to drive the rotation and location of my edge.

enter image description here

So I copy this z rotation with a simple driver, and my original script gets the z rotation input from this proxy. Now it works perfectly regardless of the interpolation.

It is important to note: That the one frame latency occurred, because in the question the driver and driven properties belonged to the same object. In a case when these porps reside on different object it should not occur.

I experimented further this issue, and the problem also shows itself if two objects mutually drive themselves.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.