PDA

View Full Version : Spinning Fan Project


debooh
11-03-2009, 01:08 PM
I found another way to solve this fan spinning project but I really can't figure out why the attached project does not work. Can anybody enlighten me on what I am doing wrong?

:confused:

Thank you

x2495iiii
11-03-2009, 10:39 PM
What I'd do is delete all of your boolean variables, then make one number variable called speed under the properties tab of the world (NOT in the method). Then, have the off button set speed to 0 when clicked, the low button set it to one, and so on for the other two buttons. Then, make a new "while the world is running" event which calls one of the methods in the During part of it (which basically means the event wil be called over and over while the world is playing). Finally, have the method that is called in the During part of the event contain a nested if/else if method which looks like this:

if speed == 3
fan.blades roll left .1 revolutions [duration = 0 seconds] [style = abruptly]
else
if speed == 2
etc.

I tried this myself, and it works wonderfully.

antmj2317
11-03-2009, 10:56 PM
What I'd do is delete all of your boolean variables, then make one number variable called speed under the properties tab of the world (NOT in the method). Then, have the off button set speed to 0 when clicked, the low button set it to one, and so on for the other two buttons. Then, make a new "while the world is running" event which calls one of the methods in the During part of it (which basically means the event wil be called over and over while the world is playing). Finally, have the method that is called in the During part of the event contain a nested if/else if method which looks like this:

if speed == 3
fan.blades roll left .1 revolutions [duration = 0 seconds] [style = abruptly]
else
if speed == 2
etc.

I tried this myself, and it works wonderfully.

There's an even easier way.

Create a global variable and give it a starting value of 0

Create events to assign different values to the variable per button.

In 'main', write a single line of code..

while true
fan.blades->roll at speed [global variable] per second

When the event's are executed, the variable in the infinite while loop will have it's value substituted.

x2495iiii
11-03-2009, 11:01 PM
That would work too, but you'd have less control over the fan's animation (my code allows for smooth turning and quick stopping, yours yields either choppy animation or slow stopping due to the need for a static, non-zero duration and the fact that the style cannot be changed to abruptly).

fatdu4
11-27-2009, 08:36 AM
Could you guys please attach your projects, I'd love to compare and learn from 'em. Thanks.

dubastot
11-27-2009, 11:48 AM
They aren't going to post what they did for you. It is up to you to listen to what they said and try to do that in your animation.:cool: