5. You want to move a character smoothly left and right using the horizontal axis, but only when the input magnitude is greater than 0.1 to avoid tiny unwanted movements. Which code snippet correctly implements this in Unity C#?
A)
float h = Input.GetAxis("Horizontal");
if (h > 0.1f) {
transform.Translate(h * speed * Time.deltaTime, 0, 0);
}
B)
float h = Input.GetAxis("Horizontal");
if (Mathf.Abs(h) > 0.1f) {
transform.Translate(h * speed * Time.deltaTime, 0, 0);
}
C)
float h = Input.GetAxis("Horizontal");
if (h > 0.1f && h < -0.1f) {
transform.Translate(h * speed * Time.deltaTime, 0, 0);
}
D)
float h = Input.GetAxis("Horizontal");
if (h != 0) {
transform.Translate(h * speed * Time.deltaTime, 0, 0);
}