Why I can't spawn my bullet


This is my gun’s blueprint. Why this doesn’t spawn the bullet actor? I am sure that my input action works but this part doesnt work at all.

put a print string after the spawn to check if it is triggered.
Make sure BP bullet has it’s static mesh setup correctly to see the bullet.

Yea I was sure because I saw it works fine on showdebug input. But It doesn’t trigger somehow. The things I did is create IA_Fire, add it to Input mapping and thats all.

and you have the input mapping setup => Enhanced input subsystem => add context mapping => your mapping picked

This is my gun’s blueprint.

What BP is this? Non-possessed Pawns do not process input. Actors do not process it at all unless enabled explicitly. If the gun is just an actor, it won’t fire.

  • either enable input on the gun
  • or have the pawn / controller handle firing and tell the gun to fire via a custom event
2 Likes

Yeah this is an actor blueprint. How do i enable input?

You don’t. You should have your player controller or player pawn trigger the event through a reference.

You can enable auto input for controller 0 but it’s a hacky way that should only be used for testing.

2 Likes

In the video I watched he was doing the hacky way. So I think I should put these codes to my character right?

Yes the character holds the weapon and they should be the trigger to fie it.

Seconded. @Aga45678 Let’s say you enable input and add a second gun, now you have a much more complicated issue where 2 actors fight for input priority. If there is one gun only in the entire game, that’d could work OK-ish.

Yup, the character surely knows which weapon is active / equipped.

1 Like

Btw how do i get the new location of gun everywhere I go? It disappears when i pick it up but when i get the location of it, it calculates the old location

How do you pick it up?

I attach it’s mesh to my hand socket

What node is used to pick up the gun? Begin Overlap? If so, where? In which BP?

Btw how do i get the new location of gun everywhere I go?

And you may need to elaborate on what this means, precisely?

I did these in c++



When I shoot it shoots from it’s location where I picked it up. How do i shoot from where I attached it to?

Normally, you’d add a socket to the gun mesh or place a scene component indicating muzzle location. Spawn bullet at that world location (you may also want to work in direction).

On overlap you should save the weapon as a reference to a UPROPERTY in your character.
You can then access the weapon (and it’s socket location) when firing.

1 Like

So I created this variable at gun class header
image
Now what I need to do?

It needs to be in the character’s header. The character equips the weapon :wink:


I made it like this now I can reach it from blueprint. But still when I do like this it spawns on old location