PDA

View Full Version : physics error



AdamZZ
February 4th, 2007, 04:44 PM
im back and now im working in another game xD but this time its halo.

i have some problems with my physics >.< heres the code



onClipEvent (load) {
down = false;
inair = false;
falling = false;
jumping = false;
speed = 0;
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.SPACE)) {
jumping = true;
}
if (jumping) {
if (!inair) {
if (!falling) {
speed += 0.85;
this._y -= speed;
if (speed>15) {
falling = true;
}
} else {
speed += 0.90;
this._y += speed;
falling = true;
if (_root.ground, hitTest(this)) {
speed = 0;
falling = false;
inair = false;
jumping = false;
}
}
}
}


when i press space i jump then when im starting to go down it stops and im not even near the ground :S can someone pls tell me whats wrong ?

Nich
February 4th, 2007, 05:09 PM
shouldn't

ActionScript Code:

if(_root.ground , hitTest(this))





be written as

ActionScript Code:

if(_root.ground.hitTest(this))





?

Correct me if I'm wrong

AdamZZ
February 12th, 2007, 03:03 PM
yeah you were right ^^ i got it now, looked at the platform tutorial and got a good hittest function ^^