I wanted to make my 2d character stick to the ground. In my movement I get var velocity = _rb2d.velocity, do some stuff with it and then set the rigidbodies velocity to the var.
I got it to work, but adding acceleration somehow broke it. It works fine when working on flat ground fine, but when walking down or up a slope character moves at a snails pace
This is the code for slope forces:
velocity = velocity.x * -Vector2.Perpendicular(hit.normal);
else
velocity = new Vector2((velocity.x * -Vector2.Perpendicular(hit.normal)).x, -2);```
(Move calculation is done right before the code above)
The move calculation which works fine:
```velocity.x = MoveDirection * Speed```
but this doesn't:
```velocity.x = Mathf.MoveTowards(velocity.x,Speed * MoveDirection, acceleration * Time.deltaTime);```
Again on flat ground fine, but not on slopes
