player movement based on slider value?

Hey guys i’m trying to make my player object move left if the slider value is at 1 and make it move right if the slider value is at 2. Any idea on how to do this?

You will want to convert the slider value to a direction (-1 to +1).

float speed = 1.0f; // use this to control how fast the player moves

// convert slider range (1 to 2) to half-unit direction (-0.5f to +0.5f)
float direction = sliderValue - 1.5f;
// convert to unit range (-1 to +1)
direction *= 2f;

player.transform.position.x += direction * speed;