PDA

View Full Version : Problems with simple IF expression


ajp303
11-21-2005, 10:16 AM
I've currently got a large number of delegates that are working their way through a simple corridor with their z-positions at 0. To those I've linked some geometry to them. After calculating the crowd sim I would like to change the position of the linked geometry to make them appear as if they are going down a ramp.

The following code doesn't seem to work. If I take out the 'if' expression and just set theObj.pos.z to a number it does change. Any ideas where I am going wrong ?


theObj = selectByName()
if theObj != undefined do
for t = animationrange.start to animationrange.end by 5 do
if theObj.pos.x > 12.5 then at time t with animate on theObj.pos.z = (theObj.pos.x - 12.5) * -1


(the crowd sim sets keyframes every 5th frame)

Thanks

ajp303
11-23-2005, 01:05 PM
I've cracked it after many hours and going through the maxscript help (new to it all).
I needed to set keyframes on the object first so I could get and set $.pos.x etc

The code works and I just need to tidy it up into one for...do loop.


for i in 1 to $selection.count do (
deleteKeys $selection[i][3][1]
)

for i in 1 to $selection.count do (
for t = animationrange.start to animationrange.end by 5 do (
at time t with animate on $selection[i].pos = $selection[i].pos
)
)

-- check down
for i in 1 to $selection.count do (
for t = animationrange.start to animationrange.end by 5 do (
at time t (
if ($selection[i].pos.x > 12.5 and $selection[i].pos.y < -6) then (
with animate on $selection[i].pos.z = ($selection[i].pos.x - 12.5) * -0.5
)
)
)
)

CGTalk Moderation
11-23-2005, 01:05 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.