PDA

View Full Version : Another script error


AyTrane
04-18-2012, 06:14 PM
Error: "No ""="" function for (%"not"() SystemGlobal:sliderTime)"

What I'm attempting to do is have the sliderTime progress (starting at frame 1935) until reaching 5000f. Meanwhile, the percent controller will adjust according to the distance between Dummy005 and Dummy008 by using this distance to calculate velocity (v) and time (t) between frames, while also returning a percent value (pct) for Dummy005 to move along it's path.

What foolish mistakes have I made now?


(--start a local scope.
(
local theDummy = $Dummy005 --set dummy
SliderTime = 1935
while not sliderTime = 5000 do ( --loop until slider reaches 5000 frames
theTime = sliderTime.frame + 5 --Move slider five frames
with animate on --enable autokey animation context
at time theTime --set the current time for the following expression
z = distance $Dummy008 $Dummy005
v = (SQRT(2*32.2*z))
t = v*(1/6)/949.509
pct = sliderTime.frame - 5
theDummy.position.controller.percent = pct + t
)--and set the percent along path
)--end if
)--end script

Pjanssen
04-18-2012, 06:20 PM
The single equals sign (=) is an assignment operator, while the one you're looking for is the double equals sign (==), which is the comparison operator.
Also, to make sure you might want to add parentheses. I'm not sure about the precedence of the not operator, but it's a bit clearer if nothing else:
while not (sliderTime == 5000) do ( --alternatively use not-equals operator: !=
However, it might be nicer to write it like this instead:
while sliderTime <= 5000 do (
This will avoid issues with the loop never ending if for some reason sliderTime never becomes exactly 5000 after an iteration, but overshoots it.

AyTrane
04-18-2012, 08:01 PM
I figured out a better way to write my code, but I don't know how to recall the percentage along the path from the previous key. Anyone have any ideas?


(--start script
local theDummy = $Dummy005 --set dummy
with animate on --enable autokey animation context
(
for i=1090 to 5000 by 10 do /*Create key at every 10th frame within 5000 frames*/
(
at time i
(
z = distance $Dummy008 $Dummy005 --get distance between two dummies
v = (SQRT(2*9.81*z)) --use distance in velocity equation
t = (v*(1/3)/949.509) --calculate distance along path for 1/3rd second, then divide by total spline length to get percentage change
pct = <need old path percentage here> --get previous percentage at last keyframe
theDummy.position.controller.percent = pct + t --add percent change and previous percentage along path to locate new percentage along path, and set.
)
)
)
)--end script

CGTalk Moderation
04-18-2012, 08:02 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.