transform.Rotate() not working

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Move : MonoBehaviour {

Rigidbody rb;
public int speed = 10;
public int jumpHeight;
public int rotateSpeed;

    // Use this for initialization
    void Start () {
       
        rb = GetComponent<Rigidbody>();
    }
   
    // Update is called once per frame
    void FixedUpdate () {
       
        if(Input.GetButtonDown("A")){

            transform.Rotate(Vector3.up * -rotateSpeed * Time.deltaTime);
        }

        else if(Input.GetButtonDown("D")){

            transform.Rotate(Vector3.up * rotateSpeed * Time.deltaTime);
        }

        else if(Input.GetButton("W")){

            rb.velocity = new Vector3(0,rb.velocity.y,speed);
        }


        else if(Input.GetButton("S")){

            rb.velocity = new Vector3(0,rb.velocity.y,-speed);
        }


        else if(Input.GetButtonDown("Jump")){

            rb.AddForce(Vector3.up * jumpHeight);
        }

        else{

            rb.velocity = new Vector3(0,rb.velocity.y,0);
        }
    }
}

Currently in the process of switching from JS to C# (not saying that’s the problem, maybe I’m just an idiot), and as usual I’m running into problems. The object doesn’t rotate with A and D for some reason.

This is just one problem; a lot of transform.Whatever() methods just refuse to work for me in C#. What am I doing wrong?

Does rotateSpeed actually have a non-zero value? That is, you set its value in the inspector? By default int values are 0.

Although I’d actually be surprised if this was the case as I’d have thought Unity would give you warnings/errors in the console about trying to rotate with a zero vector…

Also, you’ll want to use Update() instead of FixedUpdate() since that’s really meant for physics components. Using Time.deltaTime inside of FixedUpdate will likely give you odd results.

Time.deltaTime returns Time.fixedDeltaTime when used in FixedUpdate.

You’re using GetButtonDown, which will only return true on the first frame the button is pressed. By your use of Time.deltaTime, I imagine you meant to use GetButton which will return true as long as the button is pressed.

Haha oops. It works now, but I can’t turn while moving?

hint: If… else if…

I would actually keep your horizontal movements as an if/else if (well, frankly I’d disable rotation if both were pressed, but the choice is yours), and vertical as if/else ifs (or disable if both pressed), but disconnect the horizontal and verticals from each other in your if/else ifs, if you get my meaning. That’s the cause of the problem.