I’m following unity’s Create with Code tutorial, and am currently try to move the truck through player input. Neither Visual Studio nor Unity are giving me any errors or warnings. I have made sure to go into project settings and set input type to key or mouse button.
Here is my code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class FollowPlayer : MonoBehaviour {
public GameObject player;
public Vector3 offset = new Vector3(0, 5, -7);
public float turnspeed;
public float horizontalInput;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
horizontalInput = Input.GetAxis("Horizontal");
transform.position = player.transform.position + offset;
transform.Translate(Vector3.right * Time.deltaTime * turnspeed * horizontalInput);
}
}
,