Horizontal Input showing random decimal when it should be 0
The picture below is the Console writing my horizontal input (A, D, Left, Right) and when I'm not pressing any buttons, it shows 0.3538464, or whatever random decimal.
Here is my code for this:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerMovement : MonoBehaviour
{
void Update()
{
var horizontalInput = Input.GetAxis("Horizontal");
Debug.Log(horizontalInput);
}
}
I know that this isn't something to do with my keyboard, because I unplugged it and the same thing happened.
When I press A or D, though, they go to 1 or -1. But, when there is supposed to be no input detected (nothing pressed), it goes back to the decimal.
I've also tried reinstalling Unity, restarting my computer, installing other versions, but nothing seems to work.
Thanks in advance!
Your answer
Follow this Question
Related Questions
How can I have a life added bar every time I reach 5000 points 0 Answers
Gameobject wont set active 0 Answers
Why is my script not working 1 Answer
Unity Parsing Error CS8025 on Last Line? 2 Answers