- Home /
[Solved-ish] (Linux) Spacebar misbehaving in preview mode
I've recently run into a strange and frustrating issue while working on a practice project in a tutorial course. The issue arises when trying to instantiate a projectile from a space ship by pressing the spacebar. However, when previewing the game, nothing happens when spacebar is pressed. The ship responds to movement keys (both the arrow keys and WASD). But, no projectile.
I've done a bunch of troubleshooting (which I'll list further down). But, nothing has gotten me any closer to fixing the problem. It did however reveal a little more about the nature of it. Which, is that during preview mode, other keys will respond as expected. But, spacebar and both of the 'alt' are ignored as key presses in the game. Instead, they interact with the Editor, inconsistently toggling between the Rect Tool and the Hand Tool.
Tinkering/troubleshooting attempts:
Unsuccessfully tried both Input.GetKeyDown(KeyCode.Space) and Input.GetButtonDown("Fire1") (positive input for "Fire1" was remapped to spacebar, and alternate positive was mapped to mouse 0 (which the mouse input worked))
Created a new project, created a script, attached it to the camera, added a simple 'if statement' in Update to post a message through Debug.Log when the specified key was pressed. Created a chain of 'else if's with various keys. Letter keys would trigger a message, as would both Shift keys, and both Ctrl keys. However, spacebar and both Alt keys were ignored by the 'game' and instead interacted with the Editor, as stated.
Installed additional versions of Unity, through the Hub. Made a new project from scratch. All of them had the same behavior.
Tried using different desktop environments. Made a new project from scratch. Same behavior.
Tried installing other distributions of Linux. Made a new project from scratch. Same behavior. (Started with Manjaro, then tried Debian(Stable and Testing) and Xubuntu 20.04).
Unplugged everything from the computer, except keyboard, mouse, monitor, and ethernet cable. No change.
Tried a different keyboard and mouse. No change.
Looked to see if sticky keys were accidentally enabled. They were not.
Tried a different code editor (Normally use Jetbrains Rider; tried Visual Studio Code). Made a new project from scratch. No change.
Unmapped spacebar from all other input mappings in the project. No change.
Unmapped spacebar from every Unity shortcut it was tied to. No change.
Booted into Windows and installed Unity and Rider. Did NOT experience the problem over there. Spacebar and alt keys responded normally, and triggered Debug.Log messages in the script.
Observations:
There are no error messages in the console or from Unity itself.
The code appears to be correct (everything matches the example code from the tutorial).
Happens across multiple versions of Unity.
Happens across multiple Linux distributions.
Happens across multiple desktop environments (XFCE, Cinnamon, LXDE, OpenBox).
Happens when all peripherals, except mouse and keyboard are disconnected.
Different keyboard and mouse made no difference.
Spacebar and alt keys behave normally in all other situations.
Problem does NOT occur in Windows (spacebar and alt keys behaved as should be expected)
The problem did not exist on a previous install of Xubuntu 20.04. The keys behaved normally in the same project. I switched from Xubuntu as I was having a bunch of errors related to the Unity editor constantly popping up, that didn't occur when using Manjaro, prior. Which, I switched away from because of an unrelated scenario. It's when I switched to Manjaro for the second time that I first noticed this problem. Yet, ever since it first happened on Manjaro (with XFCE, if that matters), it's happened in every other Linux environment I've tried.
While I'm tempted to just map the "Fire1" button to a different key and move on, this problem will linger on in future projects. So, I really want to figure out how to resolve this. I've scoured this forum as well as Google and DuckDuckGo for a couple of days now. I've seen a couple of scenarios that are loosely similar. But, either the answers didn't end up resolving the problem, there were no answers at all, or the problem ended up being related to something else.
If anyone has any insight, I would greatly appreciate some help.
Thank you, in advance!
-Don
Answer by mcdnvs · Aug 11, 2020 at 10:17 AM
@DHotdog85 oof i just had that problem and apparently there is no way to solve it
https://forum.unity.com/threads/space-not-working.946974/#post-6188199
Huh. Interesting that it's a "known bug", yet finding information on it has been so tricky. But, thank you for the info! I'll try this out and report back, soon.
Answer by DHotdog85 · Aug 11, 2020 at 02:13 PM
Yep! That was it!
Same exact experience. Spacebar reports as "O", and the workaround helped. This was driving me insane! I really hope they're able to resolve the issue soon-ish (I'm sure they already have a lot on their to-do list). This is a really frustrating issue to run into. Cause, we're doing everything right, but it's just not behaving. rage flips mouse pad
Anyway, thank you SO much, @mcdnvs , for helping me find a way around this! I was dreading having to leave my cozy Linux space to continue on with Unity.
Take care!
-Don
Your answer
Follow this Question
Related Questions
Unity Editor reliable on Linux? 0 Answers
How to install Unity Editor On CentOs 7(LINUX)? 1 Answer
Can't drag GameObject from Hiearchy to Project view to create prefabs on Linux unity 5.5.1 1 Answer
Socket: accept Failed, error To Many Open Files (24)? 0 Answers
ui_scaling problem linux editor 0 Answers