Or in if statement (not working)

Hello, i want to play my animation when Vertical and Horizontal keys are pressed.
But “OR” don’t work.

if (Input.GetButton("Vertical") || Input.GetButton("Horizontal")){
anim.SetFloat("Speed", 0.2f);}

HarshadK is right, your OR operator will be firing correctly under the condition the code block provided is all that is in your Script.

Check that the “Speed” Parameter in the Animator you have attached to your animating GameObject has changed to 0.2f. If it has changed based on pressing Horizontal/Vertical inputs then your code block is working.