Hi,
I copied code from class, but the z position from the “Car” object didn’t change when the “Horizontal” Input changes. How can I move objects freely?
This is my code.
→
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class driver : MonoBehaviour
{
[SerializeField] float steerSpeed = 1f;
[SerializeField] float moveSpeed = 0.01f;
void Start()
{
}
void Update()
{
float steerAmount = Input.GetAxis("Horizontal") * steerSpeed * Time.deltaTime;
float moveAmount = Input.GetAxis("vertical") * moveSpeed * Time.deltaTime;
transform.Rotate(0, 0, -steerAmount);
transform.Translate(0, moveSpeed, 0);
}
}