I just started my coding journey in Unity and learning C#. Everything was working fine in my course video. When I had my code below I could move using “A and D” Keys on my keyboard.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Driver : MonoBehaviour
{
[SerializeField] float steerSpeed = 1f;
[SerializeField] float moveSpeed = 0.01f;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
float steerAmount = Input.GetAxis("Horizontal");
transform.Rotate(0, 0, -steerAmount);
transform.Translate(0, moveSpeed, 0);
}
}
But as soon as I added in * steerSpeed my capsol aka car only will go straight and I can no longer move my car around.
// Update is called once per frame
void Update()
{
float steerAmount = Input.GetAxis("Horizontal") * steerSpeed;
transform.Rotate(0, 0, -steerAmount);
transform.Translate(0, moveSpeed, 0);
}