Spawning Actor on Key Press doesn't work, but Is Input Key Down Does?

Hey guys! So, I am working on a little project that’ll require a shield to spawn at the location of the player. I first checked to make sure that “Block Input” was Not Enabled in my Default Settings, and then tossed in this Blueprint. I checked out a lot of videos, and these Blue Prints always seemed to work, but it isn’t working for me. Whenever I click “F”, nothing Spawns even though I have the Shield Selected for the Class on Spawn Actor.

If I drag the “Pressed” for “F” to the Print String, that doesn’t work either. However if I drag “True” on the “Branch” to the Spawn Actor and click on “F”, that works, but it spawns too many Shields.

I saw in some videos that people used “Get Player Character” Node, but whenever I try using that, I get “Accessed None”, but I don’t think I need it because “GetActorLocation” with it Targeting Self does return the correct Location.

I just don’t know if I am missing something or if I did something wrong somehow?

I guess I’d go through a checklist:

  • Is PIE in focus when you start it (click the play area with mouse if it does not autofocus)
  • Is game paused and is the input registered when game is paused
  • Is input mode Game Only / UI only / Game and UI
  • The Pawn / Character and the PlayerController relations are set up correctly

Enable input may not be needed, but it is impossible to tell the context in which you are working.

Another issue might be that spawning a box at actor’s location may not work if it ends up colliding with something.

I’m still new to the whole Unreal Engine 4 thing, but I will try my best to go through this Check List.

“Is game paused and is the input registered when game is paused”

Input for “Is Input Key Down” does not register when the Game is Paused.

“Is input mode Game Only / UI only / Game and UI”

I’m not entirely sure what you mean by this, or how to check, but I’m pretty sure the Input Mode is for Game Only since I don’t have any UI Elements.

“The Pawn / Character and the PlayerController relations are set up correctly”

I think so since the Blueprints to Print out the Debug Text uses the Player Controller and it works just fine.

“Is PIE in focus when you start it (click the play area with mouse if it does not autofocus)”

I’m not sure what you mean by PIE, but I do have to click the play area with my mouse when I start up the project.

Edit: I don’t think it is a Collision Issue. Because when I connect the Branch Node to the Spawn Actor Node, it works just fine at Spawning the Shield. It just spawns like ten of them instead of one. It just doesn’t seem to register when I click “F” using the Key Node or whatever its called.

In other words, it works when I do this (See Image Attached) but it just spawns too many Shields, and I know that it isn’t the correct way to utilize key inputs (see second image)

.

I believe this is what you’re talking about. Right? :open_mouth:

241271-gamemode.jpg

You sir, are a champ! Out of all the links I checked, you are literally the first person to make that suggestion! It works just fine now :smiley: Thank you for taking the time to help me out man!

PlayerControllers possess pawns or characters (which derive from pawn class) with 1:1 relation.

For every level, there is GameMode, which defines PlayerController being used as well as the Default Pawn.

Assuming you use default editor layout, click on the toolbar above 3D viewport. Under Blueprints → Project Settings, hover over GameMode, and see what it is set to. If you are in a blueprint project, you can set up the default playercontroller and the pawn directly. If you are in a C++ project, create a new GameMode blueprint and set it as the default gamemode.

Make sure that both the playercontroller and the pawn are set to what you want them to be.

Yes.

The reason why the options are greyed out is because the current GameMode is based on C++. In order to make changes to the default pawn class and the player controller class, you’d either have to do it in C++, or, the easier way, is to create a new GameMode blueprint and set it as the default GameMode.

Then you can access the options which are now greyed out.