Results 1 to 8 of 8
Thread: Jerky Jumping
Hybrid View
-
February 4th, 2004, 05:35 PM #1
Jerky Jumping
I'm currently in the middle of a game project and came across a problem. Whenever I jump in the game(please try to understand me), the character jumps normally until he hits the floor. When that happens (at the time, he is obviously lower than the floor), he jerks upward to the exact postition of the floor. I know why this happens (the computer checks if his y postion is LOWER than the floor), but I don't know how to fix it. Please help! Here is the code:
if (pc._y<floor && !jumping) {
pc._y += yvel;
}
if (pc._y>floor) {
pc._y = floor;
yvel = 15;
jumping = false;
}
if (jumping == true) {
pc._y -= yvel;
yvel -= 2;
}
if (Key.isDown(Key.UP) && !jumping) {
jumping = true;
}I don't bite... hard.
-
February 4th, 2004, 09:08 PM #2371Hungry Member
postswhat i would do is change the operator < to <=
if (pc._y<=floor && !jumping) {
pc._y += yvel;
}
if (pc._y>floor) {
pc._y = floor;
yvel = 15;
jumping = false;
}
if (jumping == true) {
pc._y -= yvel;
yvel -= 2;
}
if (Key.isDown(Key.UP) && !jumping) {
jumping = true;
}
let me know if it helps :!"When ignorance reigns life is lost"
- RAGE AGAINST THE MACHINE
-
February 5th, 2004, 05:30 PM #3
That won't work... because the code sets his y postion straight back to "floor." And if you were checking if he was equal with the floor, he would not be able to jump.
Sen! I need you!
I don't bite... hard.
-
February 6th, 2004, 02:41 AM #4180LeGourou
posts
if (pc._y>floor) {
pc._y = floor;
yvel = 15;
jumping = false;
}
Here it looks like your trying to stop the jumping... but why would the movie clip need a velocity if jumping is false.....
I could be wrong but its worth a shot
if (pc._y>floor) {
pc._y = floor;
yvel = 0;
jumping = false;
}
<B>OBCT</B>
-
February 6th, 2004, 04:44 AM #5
Hoi
this solves your prob
flash reads up to downCode:if (pc._y<floor && !jumping) { pc._y += yvel; } if (jumping == true) { pc._y -= yvel; yvel -= 2; } // moved the if() down if (pc._y>floor) { pc._y = floor; yvel = 15; jumping = false; } if (Key.isDown(Key.UP) && !jumping) { jumping = true; }
a good tip when trying solve prob's like this is to look at the code and do very thing step by step in you mind. And when testing thing you should all ways have it after a change has been made
Eidt: fixing typ0

.....
-
February 6th, 2004, 04:53 AM #6180LeGourou
postsAhhhh nicley spotted!
<B>OBCT</B>
-
February 6th, 2004, 07:29 AM #7
thanx

.....
-
February 8th, 2004, 12:36 PM #8
hey! thanx alot!
I don't bite... hard.

Reply With Quote

Bookmarks