akashenen / 2d-platformer-controller

Simple implementation of a 2D platformer character controller using raycasts for smooth and precise input and movement

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

CharacterController2D::Walk Deceleration not working

NomadArtisan opened this issue · comments

This is an amazing asset you've created, thank you!
Deceleration in CharacterController2D::Walk is only being called once, and then the speed.x will be set to 0 on the next call to walk when speed.x is assigned at line 328 of CharacterController2D

I fixed it by replacing the else at line 325 with
else if (direction != 0 && (speed.x == 0 || Mathf.Sign(direction) == Mathf.Sign(speed.x)))

I haven't thoroughly tested this fix, but it appears to work for me on initial testing.

Regards,
-NomadArtisan