View Single Post
# 1 15-02-2010 , 10:51 AM
Registered User
Join Date: Feb 2010
Posts: 4

How are expressions processed?

Hi

I'm currently in a lesson working with basic expressions. The task was to create an expression that would make an oil lamp swing on it's hinge. My original code:

PHP Code:
//values are keyed to Impact=50, Dropoff=200, Amp=30
$angleZ 0;

if (
frame Handle2.Impact){
    
$angleZ = (Handle2.ImpactDropoff frame);
    
$angleZ $angleZ * (Handle2.Amplitude 2);
}

Handle2.rotateZ sin(frame 5) * $angleZ
I put the two $angleZ parts on different lines for readability. It's simply my programming style, however it yields a very strange result: At about frame 66/67 the lamp changes direction for 1 frame. If however, I use the following code:

PHP Code:
$angleZ 0;

if (
frame Handle2.Impact){
    
$angleZ = (Handle2.ImpactDropoff frame) * (Handle2.Amplitude 2);
}

Handle2.rotateZ sin(frame 5) * $angleZ
There are no problems.

I can't see at all how the two expressions could possibly run differently, especially as the variable is modified before the angle in both cases. Can someone please explain what is happening?