Aye, this is partly what I meant by the above statement. You’d probably want a more-left and more-right check as well as the center check.
And the else if insures that the code doesn’t act if the morphball is moving upward, because of course moving upward is a negative vspeed, and thus is less than zero. Morphball moves up when bomb jumping.
Well, make sure your graviy acts under all conditions unless there’s ground below the morphball. And what does your bouncing code look like? Usually it should be as simple as dividing the vspeed by a number < -1. Aside from those, my only guess is that some other code is interfering and pushing it back up, somehow, or maybe it’s in a flux of constantly changing vspeed when it looks like it’s floating. The GM debugger can be handy at times like this.
I’m guessing that code is in the collision event with object1?
Well, it’s not going to bounce if you’re falling at a vspeed less than 3, because if it is, that if clause gets to it before the else if, and sets the vspeed to 0. (Maybe you want this?)
If you plan to have the morphball rolling up and down slopes, this may need reworking altogether, as that code could easily interfere with going down slopes. You might try only using GM’s vspeed variable for vertical movement in the air, and use your own system of manipulating the y value for slopes.
Shorthand for the line that makes it bounce would be vspeed /= -2;.
For the heck of it, I’ll play out a simple scenario:
Falling at vspeed of 10.
Bounce off ground; vspeed is -5.
Come back down. Bounce; vspeed is -2.5.
Come back down. Stop vspeed entirely, because the vspeed is less than 3.
Trying to start rolling down a slope. If there is accelleration and not just instantaneous speed, you may move horizontally, but won’t move vertically until there is no ground underneath you, because the vspeed is constantly being set to 0 by the vspeed < 3 test. (Actually this might have been the case, but I believe the while loop would keep you on the ground xP)
I hope perhaps this might help you figure out what you might need to do. I apologize for not writing much actual code for you >.>.
Hmm… I’ll refrain from commenting on or suggesting anything aside from the morphball.
But yeah, strange. It isn’t always 2 pixels, either. (I got 1 on one occasion.) And if you try to un-morph after bouncing, you just disappear? Strange. Does something else change after having fallen as a morphball? I’m wondering too - if the morphball is the same object as the character, would perhaps some of the character’s non-morphed code be interfering somehow? I can’t tell 'cuz I don’t have the code, but that might be something to look for.
Also, are you using GM’s built-in gravity, or your own gravity? I highly suggest using your own, if you’re not already.
Ah, gravity is fairly simple. Obviously, gravity is an accellerating force, so therefore, to program gravity you use something like vspeed, and increase it each step (unless there is ground below the affected object, or any other of tons of conditions you might not want gravity to act in.)
Eh, well, as it is, one would have to press the directional button and X at the EXACT SAME TIME, or rather the same frame in the game, which is not very easily acheived. I’d reccomend changing the directional key checks to simply keyboard_check, removing the _pressed.