Monday, October 19, 2009

Case 05 - Collision and gravity

The task in this case was to get our character to follow a ground when walking back and forth, and jump. To make this happen we had to program some basic physics, gravity and velocity, and add in a ground. The ground is simply a shape in a movieclip which we import into the scene.  By using hitTestPoint for the ground variable, a designated object will collide with the ground, which in this case is my character.
When we got the case we got an example code on how this is done in a .docx. I tried to implent this example into my own code, but it didn't work. Without giving me any errors, my character simply walked in the air. I later found out I just missed one single letter that prevented the whole thing to work. Fixing that everything worked as it should. I then adjusted the jumping a bit by increasing the gravity variable and the amount of velocity the character gain when jumping. Giving it a slight different feel from the example code.
I made a new jumping animation in this case, since the first one I had was rather bad. Though the new one just looks like the run animating, but slower. But it still looks better than the old one.
I got some help and tips from fellow classmates on how to make my pirate to constantly use the jump animation in mid-air untill landing on the ground, and not play any other animation when pressing left or right while airborne. This was pretty much done by adding a boolean variable.

In this weeks lab class we only got an example on the parameters we needed to complete the case. How to implent it into our code were up to ourselfs. I were pretty much done with my solution before the lab class, but it were quite informative.


No comments: