- Home /
Can't accelerate player over time
I'm trying to make the player gain speed when sliding down slopes, but I can't get it to work... I think it should be an easy fix. Here's my script :
public void Rolling()
{
RaycastHit2D slopeHit = Physics2D.Raycast(controller.raycastOrigins.bottomCenter, Vector2.down, 10, groundLayers);
float slideFriction = 0.02f;
float slopeAcceleration = 2;
//float slopeDeceleration = 1000;
//float maxSlideAcceleration = 50;
if (slopeHit)
{
velocity.x += slopeHit.normal.x * slopeAcceleration;
}
}
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220613042455im_/https://answers.unity.com/themes/thub/images/avi.jpg)