I need help with this

PlatformerTest_v1.0.wick (15.7 KB)
everytime i touch the ground the player glitches out

if(this.hitTest(Ground0)){
this.Gravity=false;
this.speed_y= -this.speed_y

ghost go down. hitTest false —> still goes down
reaches ground. hitTest true —> invert direction goes up
now is no more on ground. hitTset false —> goes down again…

in this case I would not use hitTest
a simple .y control is better himo
and when you are on ground vertical speed = 0

2 Likes

thank you so much

A couple of other thoughts:

Set Gravity to true in the default script instead of at the top and bottom of the Update script.
Your Ground0 object is only 1 pixel high so it is possible that you could jump past it if you use a hit test.
Using a hit test could be preferable to a y value test if the ground level changes during your game.
Use an else on your hit test for setting the Gravity back to true like this:

if(this.hitTest(Ground0)){
this.Gravity=false;
this.speed_y= 0
}
else{
this.Gravity=true;
}

2 Likes