Jumping in a Top-View Game
Author: | darmani64
|
Submitted: | 30th March, 2004
|
Views: | 4758
| Rated: |
|
|
This article is about how to add jumping to a game that is viewed from the top.
How to add jumping.
Jumping will be entirely animation based. Create an animation in which your character jumps. Be sure that your character jumps the entire distance. You should create a jumping and a falling animation. You can also combine the two, but that will not be covered here because if you jump off a platform and miss the next one, you will not have an animation to bring the character to the ground (but it works if you add flaming lava in between platforms instead of a pit). Be sure to invclude a "Jumping Animation has finished" event with an action of "Change animation to falling". The falling animation should show something like the character waving his arms (it should be something that is looped). You might want to add a "Landing" animation. I'm not sure if this works, but try setting the hotspot of the final frame of the falling animation lower than the first so that your character falls without events.
Unfortunately, this system requires that all of your background objects are actives.
First, you need a variable that keeps track of how high the character is. Each background piece needs a variable to keep track of how high it is. One unit of that variable will be on story. Create:
Always
+Animation Jumping is playing
-Add <Insert relevant number here> to HeightOfCharacter
(HeightOfCharacter is the variable that keeps track of how high the character is)
Always
+Animation Falling is playing
-Subtract <Insert relevant number here> to HeightOfCharacter
This will increase the height of your character when jumping and decrease it when falling. The "<Insert relevant number here>" number depends on how fast your character jumps to the next level.
I suggest that your character jumps a little more than 1 story.
Next, make it so that:
Collision between Character and <Insert floor or platform name here>
+HeightOfCharacter=HeightOfFloorOrPlatformPiece
-Change animation to Landing
This will allow your character to land.
Try creating things like:
Barriers that can be jumped over (only stop the character if its HeightOfCharacter is within a certain range. Use the "Compare two values" condition twice to check if it's in a range.)
Falling(When the character is not colliding with a floor piece of its own height, and it is not jumping, it starts falling)
Super-Jump(Make the character jump, then have it play a jump-continuation animation instead of falling)
Shadows(move it with the character normally, when the character falls, fast-loop its falling so it hits the ground in one loop. Be more advanced before trying this one.)
Hope you enjoyed it.
|
|
|