prime31 / CharacterController2D

1.07k stars 248 forks source link

ignoreOneWayPlatformsThisFrame + sloped one way platform = !!!SUPER JUMP!!! #58

Closed SharpenedSpoon closed 8 years ago

SharpenedSpoon commented 9 years ago

I submit this bug in the form of a (low FPS, sorry) gif:

ignoreonewayplatformsbug

Pretty sure I know the issue, and I would submit a pull request but I am unsure as to how you want to approach the solution. In the DemoScene.cs example, when holding "down" on a sloped platform, we do not fall through it, but still get our y-velocity multiplied by 3 - so, if we also hit jump while holding down, since we get a jump y-velocity assigned before the "falling through platforms" y-velocity, then we launch way up into the air!

Entirely possible this is a feature, not a bug :D

prime31 commented 9 years ago

That is DEFINITELY a feature! I vote for leaving it as is.

Mike

On Jul 5, 2015, at 5:01 PM, Ian Douglas notifications@github.com wrote:

I submit this bug in the form of a (low FPS, sorry) gif:

Pretty sure I know the issue, and I would submit a pull request but I am unsure as to how you want to approach the solution. In the DemoScene.cs example, when holding "down" on a sloped platform, we do not fall through it, but still get our y-velocity multiplied by 3 - so, if we also hit jump while holding down, since we get a jump y-velocity assigned before the "falling through platforms" y-velocity, then we launch way up into the air!

Entirely possible this is a feature, not a bug :D

— Reply to this email directly or view it on GitHub.

Candescence commented 9 years ago

At least let us turn if off :p

Candescence commented 9 years ago

Also, the bug can occur virtually anywhere that isn't a one-way platform. I'm not really sure how to fix it while still allowing the controller to drop down through the platform.

tfinck commented 9 years ago

A simple fix for this is simply to modify the following.

if (_controller.isGrounded && Input.GetKey (KeyCode.DownArrow)) {
                //_velocity.y *= 3f;      <-- comment this line out
                _controller.ignoreOneWayPlatformsThisFrame = true;
            }