I am currently making a 2d space shooter, similar to “Asteroids” and I’m having difficulty getting the ship to rotate when I press the A and D keys. I’m going off of an old tutorial that is likely outdated.
. The code by the end of the video was:
using System.Collections;
using UnityEngine;
public class PlayerController : MonoBehaviour {
float maxSpeed = 5f
float rotSpeed = 180f
void Start() {
}
// Update is called once per frame
void Update () {
Quaternion rot = transform.rotation;
float z = rot.eulerAngles.z;
z -= Input.GetAxis(“Horizontal”) * rotSpeed * Time.deltaTime;
rot = Quaternion.Euler( 0, 0, z );
transform.rotation = rot();
Vector3 pos = transform.position;
pos.y += Input.GetAxis(“Vertical”) * maxSpeed * Time.deltaTime;
transform.position = pos;
}
}
If somebody can explain how to change this, or at least why this code doesn’t work, that would be amazing. Thanks.