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?