As has already been stated, you have a syntax error in your nested if then else
statements. My recommendation is to avoid such nested statements as they are error-prone and convoluted. Simply call Input.GetKey
once and then call a method that uses a switch
statement to return the vector. Something along these lines.
private Vector2 ChooseVector(char key)
{
return key switch
{
('d') or ('r') => new Vector2(runSpeed, rb2d.velocity.y),
('a') or ('l') => new Vector2(-runSpeed, rb2d.velocity.y),
_ => new Vector2(0, rb2d.velocity.y)
};
}