When using the stock collision (CLAMP), character gives a little "bounce" when landing.
by David Croach · in General Discussion · 11/25/2009 (4:38 am) · 1 replies
I'm programming a small platformer, and I'm using TGB's stock physics and collision. It works remarkably well for the most part and saves a lot of time programming, but the problem is it's simply not perfect. For example, every time my character lands, he "bounces" a bit, as in he goes past the floor for a frame then resets himself to where he should be. He does this horizontally while running into a wall, as well. How can I fix this problem?
Also, I have a short-hop I programmed so that when you let go of jump he stops his vertical momentum. The code is relatively simple, but for some reason if you're frame-perfect and only press jump for one frame, he will full jump, ignoring the short hop. Any ideas on that?
I'm really hoping this community will be able to help me out, because TGB has some confusing ways about it. Please offer advice!
Thanks,
~Dac
Also, I have a short-hop I programmed so that when you let go of jump he stops his vertical momentum. The code is relatively simple, but for some reason if you're frame-perfect and only press jump for one frame, he will full jump, ignoring the short hop. Any ideas on that?
I'm really hoping this community will be able to help me out, because TGB has some confusing ways about it. Please offer advice!
Thanks,
~Dac
About the author
Torque Owner Rob Cain
Typically the reason you get that little bounce is one of the following reasons:
• If you have different jump/walk frames, their collision may be lined up wrong vertically, that is to say the collision box isn't lined up with the feet in the same way in both frames. This could cause a slight "bounce" as the sprite adjusts to the collision box when hitting the ground.
• If the character is moving fast enough, the collision may not be detected until a frame where the character is -in- the floor instead of -on- the floor. When the collision occurs, the character will bounce back up to the point of collision. To prevent this, arrange a listener to detect collision on the frame before the character lands and manually set the character to rest on the point of collision.
Hope that makes sense.