- Home /
Question by
ETMonster · Jan 30 at 06:12 PM ·
c#unity 5inputprogramminghorizontal
Horizontal Input showing random decimal when not pressing anything
The picture above is the Console Writing my horizontal input (A, D, Left, Right) and when I'm not pressing any buttons, it shows either 0.2 or 0.3. 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!
screenshot-2022-01-30-130018.png
(33.8 kB)
Comment