PDA

View Full Version : How can I make a frog move forward with user's help?


HalBen18
02-25-2014, 03:59 PM
I'm trying write a hop method that makes a frog hop in a realistic fashion with a parameter that lets the sender of the message specify how far the animal should hop. I'm not sure how to do this. Help please?

chickentree
02-26-2014, 10:54 AM
I'm trying write a hop method that makes a frog hop in a realistic fashion with a parameter that lets the sender of the message specify how far the animal should hop. I'm not sure how to do this. Help please?

I am not sure what "the sender of the message" means, but in general add a hop method to the frog and include a numeric parameter that will determine how far the frog jumps. The name of the parameter should be something descriptive like 'distance' or 'howFar'
When you are done you will have a frog with a new method 'hop' that takes a parameter 'howFar' and uses that value to determine how far the frog should jump. If you need to get a users input then make a numeric variable in the world, again called something descriptive maybe 'hopDistance'. Set the value of 'hopDistance' to whatever the user gives you and then call frog.hop hopDistance.

As far as how to make the frog look like it is hopping, below is my generic advice for these kinds of actions:

Actions in general.


Do some hops and think about what is changing / moving at different stages during the exercise. Also look at frogs hopping - google, youtube ...
Method 1 - Programming the action

Translate those movements into individual steps for the object you are using.
Try to use roll and turn actions on sub-objects whenever possible.
Be VERY careful when moving sub-objects. Sub-objects usually have their vehicle set to the next highest sub-object in the object, or to the object itself. Moving a leg for instance usually results in the leg becoming detached from the character but still moving when the character does.
Look for what actions have to happen at the same time - do together - and what groups of actions happen one after another - do in order.
Start out ruff and get it working. Break your action down into 3 or 4 major steps and get those working. Then go back and look at each step and see what you can do to make it better.
CRUCIAL when your movement is done ensure that the object is back in its initial position. It may have moved, turned around or whatever but the sub-objects should all be positioned with respect to the main object as they were before the move.
If this is not the case your movement will cause the object to gradually "fall apart" in some way. One or two repetitions of your actions might look okay but 100 reps will cause some weird behaviors.
This is especially true if you have moved a sub-object.

Method 2 - Use Poses.

Alice allows you to position a character the way you want and then capture that position as a pose. When, during the movie you change from one pose to the next Alice will not just "flip" from one position to the other but will morph giving a smoother appearance than you would expect.
Caveats
Before you move the object capture an initial pose. This allows you to return to the objects initial "configuration" i.e. all the sub-parts are back in place.
Before capturing a pose ensure the object you want is selected. If you move an arm, an leg and a foot and then capture the pose, that pose will likely be created on the object's foot. Later when you look for it on the object it won't be there. The pose still exists but you are looking at the whole object if you navigate to the foot you will see the pose.
Name the pose. While pose 1 and pose 2 might be fine if you only have two poses in the movie, when you have 6 poses you will be tearing your hair out trying to remember whether it was pose 2 or pose 4 that you want to use. This is especially true when you are trying to use something in week 7 that you created in week 4.
Remember you can move an object or sub-object during development either by using the mouse or by right clicking on the object/sub-object, selecting the action (turn, roll...) I find that sometimes the mouse is better and sometimes using the instruction is better depending on what I am trying to do.

You can use a blend of instructions and poses to accomplish your objectives.

Use these steps incrementally. Don't try to get everything working at the start concentrate on one part. Once that is done start looking at the next part.
This means that in general the mistakes you see are a result of the code you just wrote. Since you know the last step was working. Going for the all in one approach leads to a situation where, if the action does not work as expected, you have no idea where to start looking for the problem.

MrMoke
02-26-2014, 11:23 AM
Good and Professional Advice From Mark!!!

As you have already guessed, an animator's job is making it look realistic.
Start by finding a slow-motion video of a jumping frog on YouTube. I found at least two great ones.

Next, drag in a frog and create a pose that you can use to get back to original if you mess up completely.

Next create a Frog "hop" Method, and click "create new parameter" to create the distance variable. You won't need it for a while.

Now you have to figure out how recreate what you see in the videos.

As Mark mentioned, Some chose to use the editor to manipulate subparts, and save multiple poses for the object. As a programmer, I prefer to retain control by writing code to make it happen because it gives me more control over timing of individual subpart movements. Basically, you have three parts: Takeoff, Fly, and Landing with each hop, and unless you're creating a Super-Frog, you will have to make more that one hop to get to the destination.

I've attached a Quick Demo for you to examine. Yes, He's in the air, but look to see where his feet end up. Also pay attention to what can happen sometimes when using poses by clicking "Restart" a few times.

Fixing it is up to you.:D

HalBen18
02-26-2014, 05:00 PM
Thanks for the helpful posts! I have the frog moving the way I want but I can't get it to move forward the distance that the user enters. I have the parameter set and I made a variable that asks the user for a number but it doesn't move the amount entered. Am I missing a step?:confused:

MrMoke
02-26-2014, 11:12 PM
The idea behind a parameter is to pass information from the outside into the Method. The name of World variable, and the name of the Method parameter don't have to be the same, because the value of the variable is passed.

Also, telling the frog to jump the entire distance, say 5 meters, at once might not work. You might have to make a loop that jumps a meter at a time until the frog gets too close to the total distance to do it again.

chickentree
02-27-2014, 10:34 AM
Thanks for the helpful posts! I have the frog moving the way I want but I can't get it to move forward the distance that the user enters. I have the parameter set and I made a variable that asks the user for a number but it doesn't move the amount entered. Am I missing a step?:confused:

My guess is that in the hop method the parameter is not being used. Look at hop and find where you cause the frog to move forward, if there is a number there replace it with the parameter (just click on the parameter and drag it to where the number is.) Do this any place your move forward appears in the hop method. If anything else depends on the distance forward you are moving, make sure and use the parameter there as well. For instance, if the height the frog moves up and down depends on how far it is jumping then you would want to use the parameter in your calculations. Something like:
frog move up (howFar/4)

MrMoke
02-27-2014, 03:17 PM
The attached vid Frog Jump

Method has two parameters: (Distance and Speed)

Hops are one meter apiece, but will stop if remaining distance is < 1.
Thought Speed would be good for Slow Mo.

HalBen18
02-27-2014, 04:20 PM
I got it to work! Thank you both for your help! :)

MrMoke
02-27-2014, 04:24 PM
The Logical thinking skills and the desire to experiment that you are using will serve you well in any future career.