Alice Community  

Go Back   Alice Community > Alice 2 > How do I...?

Reply
 
Thread Tools Display Modes
parameter being used for number of steps
Old
clumpy
Guest
 
Status:
Posts: n/a
Default parameter being used for number of steps - 11-08-2009, 11:59 AM

im really having trouble doing the question below. Every time i make him walk one step it works then 2 steps fine but if i choose 3 or anything it doesnt do it. i know my coding must be wrong but im totally struggling with this one. I think im having brain farts



Edit your marching soldier so that the number of steps he walks forward can be passed to the method using a parameter (Hint: you may have to have separate methods for the initial step and final step. The intermediate steps could be animated using a loop.)
Test your method to make sure he can walk 1 or more steps. Save your method with a suitable name as a class method.
Remember that if we write a method as a class method we can save that functionality with the object and then export these new objects between worlds.
   
Reply With Quote
Old
x2495iiii
Super Moderator
 
x2495iiii's Avatar
 
Status: Offline
Posts: 3,508
Join Date: Dec 2008
Location: Somewhere in the Continental U.S.
Default 11-08-2009, 12:43 PM

The key is the hint about three separate methods. When the character moves from the neutral position to a walking position, he has to move a half-step, moving his limbs only a half-turn. For the steps after that first one, the limbs all move full turns and he takes full steps, meaning that it can be animated with a loop (since the steps are identical). But on the last step, he has to move another half-step to get back into the neutral position, meaning it has to be in a separate, third method, apart from the loop (you could also capture his neutral pose, then set his pose back to that neutral pose in that third method).


(')>
   
Reply With Quote
Old
clumpy
Guest
 
Status:
Posts: n/a
Default 11-08-2009, 01:08 PM

thanks for the reply. But that totally went over my head.

Im so confused about this and i feel like im hitting a brick wall.

with my soldier i have a walk method which within it has a right and left walk. (right leg and right arm and left leg and left arm) so when i put the walk method in it will will 2 steps. what i have done is step up a parameter (steps)

with a if/else ive put steps < 2
toysoldier right (walks with right side)

else
loop steps/2
toy soldier left
toy soldier right


so when i use this and choose 1 in steps one step happens and the same with 2.....he will take 2 steps but when i choose 3 4 5....it always does more then it should
im trying to get it so when i put 3 it takes three steps and same with 4,5,6.... for some reason i have came to a mental block and i can not find out how to do this. i havent came here for a quick fix as i have been on this all day and me not being able to do this has stop me from doing the others. i really cant see what im doing wrong.
im going to have another look at your reply and see if i can work it out, but at the moment im like ehhhhh.....i think i need a break but i need to do this so i can do about 6 others...
   
Reply With Quote
Old
x2495iiii
Super Moderator
 
x2495iiii's Avatar
 
Status: Offline
Posts: 3,508
Join Date: Dec 2008
Location: Somewhere in the Continental U.S.
Default 11-08-2009, 02:08 PM

What I was trying to describe earlier would be something like this:

soldier stepleft (method for soldier doing one step with left leg)

if steps == 1(
(do nothing))
else(
Loop (steps - 2) times
stepright
stepleft)

soldier atease (soldier puts him arms back at his sides and his legs back to vertical)

Hopefully this makes it simpler. I'd make an example world for you, but I have to finish my online college work first.


(')>
   
Reply With Quote
Old
clumpy
Guest
 
Status:
Posts: n/a
Default 11-08-2009, 03:09 PM

i have done what you said but i have came up with some problems;

when i put 2 in only one step is made
when i put 3 in 3 steps are made
when i put 4, 5 is made
when i put 5, 6 steps are made
   
Reply With Quote
Old
x2495iiii
Super Moderator
 
x2495iiii's Avatar
 
Status: Offline
Posts: 3,508
Join Date: Dec 2008
Location: Somewhere in the Continental U.S.
Default 11-08-2009, 05:33 PM

Oh wait, I meant for the -2 in the loop to be -1. At first I thought you might have to do one last step after the loop, but you don't you just have to reset his pose, so only 1 needs to be subtracted from the steps (to account for the first step in the first method.)

Apologies, hope that works.


(')>
   
Reply With Quote
Old
clumpy
Guest
 
Status:
Posts: n/a
Default 11-08-2009, 05:41 PM

no mate that dont work either i have tried that too. i just think i have gone wrong somewhere within this coding.
I have followed what you said but none of it works. Its probably sooooo simple but i cant seem to find out how to do it!!! arghhhhhh...lol
so the -1 and the -2 does not work, so im still at the same point as before.
   
Reply With Quote
Old
x2495iiii
Super Moderator
 
x2495iiii's Avatar
 
Status: Offline
Posts: 3,508
Join Date: Dec 2008
Location: Somewhere in the Continental U.S.
Default 11-08-2009, 06:37 PM

Well then, go ahead and post your world so I can see for myself what the problem is.

(Click reply, then scroll down to the "Manage Attachments" button to post worlds.)


(')>
   
Reply With Quote
Old
clumpy
Guest
 
Status:
Posts: n/a
Default 11-08-2009, 07:10 PM

this is the world.
Attached Files
File Type: a2w STEPSSOLDIER2.a2w (269.1 KB, 21 views)
File Type: a2w STEPSSOLDIER2 backed up on Noc 9 2009 at 0h8m52s AM.a2w (269.1 KB, 7 views)
   
Reply With Quote
Old
clumpy
Guest
 
Status:
Posts: n/a
Default 11-09-2009, 06:29 PM

can anyone help with this please
   
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



Copyright ©2023, Carnegie Mellon University
Alice 2.x © 1999-2012, Alice 3.x © 2008-2012, Carnegie Mellon University. All rights reserved.