Hello all, apologies for what feels like a newbie question, but my player object otherwise works exactly as i intend. However when i was playtesting i discovered something, when moving, the player object loses all vertical velocity when holding against a wall. Obviously this is not intended and not a behavior i want, however i don’t have any ideas how i should fix it. Here is the movement code:
void PlayerMove()
{
if (Input.GetAxisRaw("Horizontal") != 0)
{
transform.localScale = new Vector3(Input.GetAxisRaw("Horizontal"), 1, 1);
Vector2 velocityX;
velocityX = new Vector2(Input.GetAxisRaw("Horizontal") * GroundedMoveSpeed, 0);
//rb.velocity = new Vector2(velocityX.x, rb.velocity.y);
rb.AddForce(velocityX);
}
else
{
rb.velocity = new Vector2(0, rb.velocity.y);
}
}
as you can see, the line " //rb.velocity = new Vector2(velocityX.x, rb.velocity.y); "
is commented out. This was the way the character initially handled movement, until i discovered the wall-holding bug. I then tried the line after, rb.addforce. This solves the wall holding, but now the character has a sort of slow buildup of speed, which i don’t want. I was going for quick, responsive, controls. Is there a way to fix my initial way of doing it, or is addforce really the only option if i dont want some sort of overly convoluted scheme?