Need Help resolving game bugs!

I’ve created a platformer game. The problem is that sometimes my character rides to high on the platforms as well as too low. He even ends up falling through sometimes. The platforms are all in one mc. Below is the jumping and platform script.

[AS]
onClipEvent (enterFrame) {
if (Key.isDown(Key.UP) && !jumping) {
vel_y = 36;
jumping = true;
}
if (jumping == true) {
vel_y -= 2;
if (vel_y<=-15) {
vel_y = -15;
}
this._y -= vel_y;
}
if (_root.ground.hitTest(this._x, this._y+35, true)) {
vel_y = 0;
jumping = false;
}
}
onClipEvent (enterFrame) {
this._y += 16;
if (_root.ground.hitTest(this._x, this._y+1, true)) {
this._y -= 16;
}
}
[/AS]

Any ideas on how fix either of this aspects would be a great help! Thanks in advance :).

It’s due to frame rate andf how many pixels your guy is falling… I’d suggest that when your character hits the platform… Put the character up to the right level right after that… No matter what.

How do I do that?

if (_root.ground.hitTest(this._x, this._y+35, true)) {
vel_y = 0;
jumping = false;
}

Take that statment… and add in…

this._x = ###; whatever the high point of the ground is.

How do you know what the high point is though. Besides I have multiple platforms in one mc, so that would make multiple high points.

TEst it… See how thick the mc is… You can do tests for this… And then test the loction of the actual MC clip… Now… You can do a test to figure out exactly how much you should displace your character from there.

Ok I did that and put in a value, but when I test it, my guy always snaps back to the original platform(the one he’s standing on in the picture) in mid jump. But I still don’t see how I would resolve the multiple high point issue. Here’s what the game looks like. As you can see It’s in one huge mc(the platforms)…so as long as I define one high point it screws me up even more

onClipEvent (enterFrame) {
this._y += 16;
if (_root.ground.hitTest(this._x, this._y+1, true)) {
this._y -= 16;
}
}

what on earth is this part doing? Try…

[AS]onClipEvent (enterFrame)
{
if((jumping == false) and(_root.ground.hitTest(this._x, this._y-2, true)))
{
this._y -= 2;
}
}
[/AS]

Thanks but when I tried that my guy jumped really high and landed like 3 cm of the platforms so…

[AS]onClipEvent (enterFrame) {
if (Key.isDown(Key.UP) && !jumping) {
vel_y = [A LOWER VALUE!!];
jumping = true;
}
if (jumping == true) {
vel_y -= 2;
if (vel_y<=-15) {
vel_y = -15;
}
this._y -= vel_y;
}
if (_root.ground.hitTest(this._x, this._y+5, true)) {
vel_y = 0;
jumping = false;
}
else if (_root.ground.hitTest(this._x, this._y+10, true)) {
vel_y = 0;
jumping = false;
}
else if (_root.ground.hitTest(this._x, this._y+15, true)) {
vel_y = 0;
jumping = false;
}
}[/AS]

Ok Thanks I tried that and the only problem now is that the guy doesn’t fall off of a platform if I just walk off, I have to jump off for him to fall.I didn’t fall through any of the platforms though.

*Originally posted by junahu *
**[AS]onClipEvent (enterFrame) {
if (Key.isDown(Key.UP) && !jumping) {
vel_y = [A LOWER VALUE!!];
jumping = true;
}
else if(!(_root.ground.hitTest(this._x,this._y,true) && !jumping)
{
jumping = true
}
if (jumping == true) {
vel_y -= 2;
if (vel_y<=-15) {
vel_y = -15;
}
this._y -= vel_y;
}
if (_root.ground.hitTest(this._x, this._y+5, true)) {
vel_y = 0;
jumping = false;
}
else if (_root.ground.hitTest(this._x, this._y+10, true)) {
vel_y = 0;
jumping = false;
}
else if (_root.ground.hitTest(this._x, this._y+15, true)) {
vel_y = 0;
jumping = false;
}
}[/AS] **

Ok So everything’s working great except now my guy sinks like a cm into the platforms, but the hitTest and falling is solid. I tried playing around with the values but it really didn’t change much. So how do I make sure that he is level with the platforms? Is there A value I’m forgetting to change?

[AS]
onClipEvent (enterFrame) {
if (Key.isDown(Key.UP) && !jumping) {
_root.boing.play();
vel_y = 20;
jumping = true;
} else if (!(_root.ground.hitTest(this._x, this._y, true)) && !jumping) {
jumping = true;
}
if (jumping == true) {
vel_y -= 2;
if (vel_y<=-15) {
vel_y = -15;
}
this._y -= vel_y;
}
if (_root.ground.hitTest(this._x, this._y+2, true)) {
vel_y = 0;
jumping = false;
} else if (_root.ground.hitTest(this._x, this._y+10, true)) {
vel_y = 0;
jumping = false;
} else if (_root.ground.hitTest(this._x, this._y+15, true)) {
vel_y = 0;
jumping = false;
}
}
[/AS]