Car is always moving after pressing play

The car is always moving after pressing play, it doesn’t stop after pressing an input and changing direction either.

Even after copying and pasting the code from the repo the car is constantly moving.

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;
        float moveAmount = Input.GetAxis("Vertical") * moveSpeed;
        transform.Rotate(0, 0, -steerAmount);
        transform.Translate(0, moveAmount, 0);
    }
}

This script is not the one moving the car, something else is. What other components do you have on the car?

None I am aware of

That is interesting. Is the ‘Player Car’ a root object in the hierarchy?

Using Debug.Log to output `Debug.Log(Input.GetAxis(“Horizontal”));

image

That should be 0 right? The button is not pressed

When I press left or right it changes to 1 and -1 but unpressed goes back to 0.95…

Yeah, that would be your problem. Something is wrong with the Input. You can check the config for input in the Project Settings

but if you made no changes, I wouldn’t know why it wouldn’t be default

I am also having the same problem… my gameobject keeps on moving on its own. Second Im not able to increase speed with vertical up and down.

So here is what fixed it for me. I had a set of sim racing pedals plugged in which was giving a constant input which was picked up by unity. Unplugging that device fixed my issue.

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms