I have a multiplayer project with two players. One player can create a game session and then he waits in a lobby level for the other player. When both player is connected, the host launches the game using seamless travel and loads the actual game map. This part is working fine. However, any input is only working when I play in PIE mode. An exception to that is if I start the game in Standalone mode while the loaded level in the editor is the actual game level. This way I have input as expected, but I can only test with one player. In a Packaged Project, there is no input either at all, but I can host/join/start the game and spawn the players just fine.
After a lot of testing I came to the conclusion that input is only working if the game was launched from the editor and the game map was the currently loaded one. What I mean by no input is that I use a Print String to display the Axis Values and it is showing 0 no matter what I press. I used the Project Settings-Input tab to setup the Axis Mapping and I use a Pawn to respond and move a camera around. Again, everything is working as expected in the editor.
Is this a known bug or there might be something I missing?! I can provide more details if needed.
Any help would be appreciated.
I have a few questions for you that will help narrow down what issue it is that you are experiencing.
- Can you reproduce this issue in clean project?
- If so, could you provide a detailed list of steps to reproduce this issue on our end?
- Could you provide screen shots of any blueprints that may be involved in this issue?
Thank you very much for your answer. I will try and reproduce the issue in a new project today as soon as I can. In the meantime, could you please let me know if there is any possible situation where a project behaves differently when run in Standalone or as a Packaged Project, than in the editor?
I was able to reproduce the issue in a new project, but I am not sure if I can call it a new project anymore, since I had to build several things in order to replicate my other project, but I tried to only include what is absolutely necessary. My problem is slightly different now, but still the same nature tho: No input. In the new project, I have no input at all, but that might be due to the fact that I built it quite quickly, but the basic issue is still there.
In short, after my game level loads up I collect the Player Controllers in the Game Mode blueprint (Get All Actors Of Class) and make an array of them. I have a few spawnpoints placed in the level (Target Points), I make an array of those as well and then I spawn my Player Pawns, using the two arrays (Player Controller array as the PlayerController of the pawn and SpawnPoint array for location). This all working fine, when I load the level both players possess a pawn without any problems. But I only have input if I play in the editor (basically what I desrcibed in my original question). I use a Print String to display the Axis Value of the pressed input but it is 0 no matter what I press, so the game executes the AddActorLocalOffset node, but doesn’t do anything, since it receives a value of 0, and this is the part I can’t wrap my head around.
What am I missing?
I can provide screenshots or more detail if needed and it helps, later today.
Thanks in advance!
I made some screenshots, I hope it will help visualize the problem.
I have a “LobbyLevel” where the host player waits for the client to join. This level has its own game mode: “LobbyGameMode”. It uses a player controller called “PreGamePlayerController”.
When both player is ready, host launches the game using a console command “ServerTravel PrototypeLevel?listen” (the actual game level).
“PrototypeLevel” uses a game mode called “InGameGameMode” which has “InGamePlayerController” assigned.
Here is a screenshot of “InGameGameMode”, where I register the player controllers every 0.3 seconds and put them in an array called “ArrayOfRegisteredPlayerControllersInGameSession” (ikr, my names are pretty long:P). I am using the elements of this array later on to assign player controllers to each player when I spawn them.
Same Blueprint, this runs at EventBeginPlay after a short delay to let the player controller register run a few loops. Here I spawn both players (“MasterCommander” which is a Pawn) using pre-placed TargetPoint actors in the level as spawn locations.
This is the last Blueprint I think might be relevant, this is the “MasterCommander” Player Pawn, where I implemented the camera movement (player is only a camera attached to a spring arm). and then use a PrintString to display the X Axis Value.
Again, both Player can successfully spawn in every situation, but there is only input if I run the game from the editor while “PrototypeLevel” is open (so the game starts from that map not from the menu).
If I try and run the game in any other scenario (like launching from the lobby) there is no input, players still spawn and AddActorLocalOffset still gets executed, but since the printed input value is 0.0 it is expected that it won’t do anything.
Any more details I could provide to help to track down the issue?
After some further testing I’m getting weirder and weirder results. I created a “Left Mouse Button Event” in “InGamePlayerController” connected to a Print String to let me know when the left mouse button was clicked and I also created a Widget with a Button connected to some logic. The result is, when I run the game from the editor as described above, everything works as expected, however in the other scenarios (also described above) the “Left Click Event” doesn’t fire, the text dosen’t get printed, but the Button and the logic connected to that works. I really hope this strange behaviour will help narrow down the isuse.
Thank you for the additional information. Would it be possible to for you to provide the clean project that you created above? This can be done via drop box or google drive. This will help insure that we are on the same page.
Thanks for getting back to me. I uploaded the test project as you requested, here is the link: Dropbox Link
Just to clarify, the screenshots above were not from the test project but from the actual, however it uses pretty much the same setup. So in the test project if you try and package the game (I used 64bit Windows -Development), then launch it, you will have no input in the game level, except the UMG Button element.
If you need any further information please let me know.
EDIT: The Launch button from the lobby stays on screen even in the game, don’t mind that, I forgot to remove it.
Do you have any updates on this issue? We are still trying to find the problem, but the inconsistent behaviour between the editor and the packaged game (or also in editor without having the PrototypeLevel loaded) is something we cannot figure out. We thought that it might be something with some of the .ini files being created empty in the packaged project folder (including Input.ini), but this does not explain why is it not working in the editor then, when not the PrototypeLevel is the currently loaded one.
Thanks in advance!
After taking a look at your project, I was able to get the input working by placing a set input mode game only on the click event for the button that shows up in game. This tells me that error appears to be how your input is being handled. It appears that you are setting your input to UI only somewhere and not setting it back. The reason this could be working in editor but not in a packaged project is because the spawn order for things are not always the same as they are in editor. This may mean that what ever is setting your input mode to UI only could be getting called in the wrong order. I hope that this information helps.
Thank you very much Rudy, I can confirm what you’ve just said, some objects spawned in different order. With this knowledge, we could solve the issue. Thanks again!