prime31 / CharacterController2D

1.08k stars 248 forks source link

DemoScene bug: Pressing Up & Down causes jump at 3x velocity #92

Closed sky-coding closed 6 years ago

sky-coding commented 6 years ago
if( _controller.isGrounded && Input.GetKeyDown( KeyCode.UpArrow ) )
{
    _velocity.y = Mathf.Sqrt( 2f * jumpHeight * -gravity );
    /* ... */
}

/* ... */

if( _controller.isGrounded && Input.GetKey( KeyCode.DownArrow ) )
{
    _velocity.y *= 3f;
    /* ... */
}

_controller.move( _velocity * Time.deltaTime );

Due to the above code, player can press up & down arrows simultaneously to launch themselves into the air at 3x jump velocity.

sky-coding commented 6 years ago

Also, I would love to purchase this as an asset on the asset store to support your work, if you are interested in selling it or other quality 2d assets!

prime31 commented 6 years ago

The example in the demo scene definitely is not a production input system. It is just the bare minimum amount of code to setup a demo of how the CC2D works.

There may be something coming to the Asset Store (a revamped and full-fledged CC2D) but no guarantees unfortunately. It is for a project where I do not get to decide the fate of the code so it’s in someone’s elses hands at the moment.