I’ve been having problems with the variables in my code
When I make the ints rotationLeft and rotationRight public, I cannot change the variables. When I run it in Unity, it just uses the variables rotationLeft and rotationRight were when they weren’t public. When I make them private again, I can change the variables as I please.
public class Rotation_Pivot : MonoBehaviour {
private Rigidbody2D rb2d;
int rotationLeft = 4;
int rotationRight = -2;
void Start()
{
rb2d = gameObject.GetComponent<Rigidbody2D>();
}
void Update () {
if (Input.GetKey("right"))
{
rb2d.transform.eulerAngles += new Vector3(0, 0, rotationRight);
}
if (Input.GetKey("left"))
{
rb2d.transform.eulerAngles += new Vector3(0, 0, rotationLeft);
}
does anyone have any idea what could be going on?