S
S
Sr_Arthur2022-02-04 09:35:18
3ds Max
Sr_Arthur, 2022-02-04 09:35:18

Why does a loop in MaxScript produce such a result?

Good day everyone. Recently started learning scripting in MaxScript for 3d max and ran into the following problem:

s = sphere ()

for i=1 to 5 do
(
a=copy s pos:[i*50, 0, 0]
if (s.pos. x>150) then
(
s.pos.z=50
)
)

A small script that first creates a sphere, and then copies it 5 times through a loop, with the condition that when the X coordinate value becomes more than 150, then the Z position value must be assigned the value 50. As a result, the script simply makes 5 copies without changing the position in Z. Moreover, there is a slight oddity when I replaced the comparison operator with the reverse one, that is, (s.pos.x < 150), then one sphere still changed its position in Z=50, but the strangest thing is that it was the very first sphere , which was created at the beginning of the cycle, and how it took this value from the if statement is not clear to me at all ...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladislav Bodyul, 2022-02-06
@BodyulCG

Replace s.pos with a.pos in two places

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question