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.
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).
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...
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.)
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.