x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

Gamemode.h Blueprint keyboard input to quit gamemode

Hello,

I have tried to build something into my gamemode, so that when I press "Escape" the game shuts down. The script I built is very simple, and shown below.

The thing is the breakpoint is never hit when I press the button. I have tried a working keyboard input, which works in my character blueprint.

It strikes me that because the Gamemode Blueprint inherits from Gamemode.h much of the input doesn't work, for example "Enable Input" can't be dragged into the Gamemode blueprint? alt text

What is the correct way of getting this to work? Have the character flag that the end is nigh and then the game mode shutdown based on the character?

I have checked the defaults and believe that the Gamemode blueprint is pointing at the Playercontroller, yet still no input routes through to the Blueprint: alt text

Product Version: Not Selected
Tags:
more ▼

asked Sep 24 '14 at 09:37 AM in Blueprint Scripting

avatar image

PompeyPaul
169 19 21 27

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

Hey PompeyPaul,

To enable input in the GameMode BP, you'll first need to Get Player Controller and then drag off that to find the Enable Input node. If you do that on Event Begin Play, your GameMode will be able to accept your InputAction Quit.

It is generally bad practice to have any input going through your GameMode if not necessary, though it is possible. Instead, you could set this up in your Player Controller or in your HUD.

Hope that helps!

more ▼

answered Sep 24 '14 at 06:53 PM

avatar image PompeyPaul Sep 25 '14 at 09:42 AM

Thanks for the info. Why is it bad practice for the GameMode to take input? I think it would be even odder to have the HUD handle the "Quit Game" event than the Game Mode?

Made the changes and it now works sweetly =D

avatar image Ben Halliday STAFF Sep 25 '14 at 06:16 PM

The GameMode is used across the entirety of your game, so it's generally best to use it as little as possible for functions that could be used in a smaller, more contained BP. Any input used in the GameMode BP can be used by any player at any time at any point in the game, and that may be what you want but it may also cause more problems down the line when you want to make changes to the game, convert it to multiplayer, etc. There are always exceptions, but that's the general reasoning: modular design would have you place these functions in a safer place.

Glad you got it working, though! Let me know if you have any other trouble with it.

avatar image PompeyPaul Sep 26 '14 at 08:54 AM

Thanks. Does the GameMode persist across level loads?

avatar image Moss Sep 26 '14 at 09:33 AM

No it does not, each level can have its own game mode. The flow would be GameModeA -> TransitionGameMode -> GameModeB.

avatar image Ben Halliday STAFF Sep 26 '14 at 03:52 PM
(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question