Rotating object on one axis using Input.GetAxis

I’m very new to C# and I’ve been reading the lessons and anything I could find here on Unity Answers. I’ve been failing to understand this code… not sure if I’m close or very far off.

using UnityEngine;
using System.Collections;

public class RotateTriggers : MonoBehaviour 
{   
	public float speed = 5.0f;
	
	void Update () {
		
		Vector3 v3 =  Vector3(0.0, Input.GetAxis("Horizontal"), 0.0);
		transform.Rotate(v3 * speed * Time.deltaTime);

	}
}

All I’m looking to accomplish is to use an axis control (in this case the Xbox 360 Triggers) to rotate an object smoothly on one axis (I understand that may not be strictly what is happening).

Any help appreciated (if I’m going about this completely the wrong way, please feel free to change my approach).

When posting a question, please explain what is going on, and what is your desired behavior. For example I can see the code above would not compile, so including the compiler error messages (copied directly from the console) is really helpful in getting to an answer. As for your code, you can simplify it to:

using UnityEngine;
using System.Collections;

public class RotateTriggers : MonoBehaviour {   
	public float speed = 5.0f;
	
	void Update () {
		transform.Rotate(0.0f, -Input.GetAxis ("Horizontal") * speed, 0.0f);
	}
}

Note in this case, you don’t need to use Time.deltaTime since that is factored to some degree by the value return by Input.GetAxis().

after i turn it, even tho im not pressing the button, it still continue turning. how can i fix that?

Thanks man!