Download

Shooter Gun System

When aiming, the gun position at each frame is determined by the two variables IkLocationAiming and IkRotationAiming (in the 1st person anim blueprint). IkLocationAiming is the exact location of your sight and IkRotationAiming is the exact rotation of your sight. They are calculated each frame in the event graph of the anim blueprint, from the camera position, and applied to the gun (actually to the character’s hand) in the anim graphs of the idle and walking states (the only two states in which you can aim). If you want to make the gun swing, I would first try generating an offset (a vector variable) each frame to add to IkLocationAiming in the event graph. But from your question, I think what you want is a sway that’s not calculated, but comes from the underlying anim sequence instead? I think you will have to try using a CopyBoneDelta node, to copy the original movement from some bone to the hand or hand IK bone. Since I never implemented these kind of sways before, I’m sure they will require a good amount of testing and work.

This question I did not understand…

You mean animating the gun bones or the character bones? For the character, you just go to the gun’s blueprint and change the ReloadEmptySequence and the ReloadLoadedSequence variables (in the “Customization - Animations” category) so they point to your own anim sequences. If you want to animate the gun bones instead, currently the project doesn’t have good support for that. That’s because the gun actor component is currently treated as PoseableMesh instead of SkeletalMesh (but the gun mesh is still a skeletal mesh). This will be changed in the near future. With the PoseableMesh replaced by a SkeletalMesh component, a reload anim could be implemented by importing a reload sequence to the gun’s skeleton and playing it when the character plays it’s own reload sequence.

Hello, i have another Question. How the Character run with a server. I read about it in the AnimBP from the First Person? What i have to do to set an BP_Character with the running from a server on it? Sorry for my bad english but the logic only confuseing me a bit.:o

The AnimBP only does the animation. When you press Shift, the InputActionRun in the B_DemoCharacter blueprint is called on your machine, and this sends an RPC to the server (ServerRun). In the server, this RPC changes the MaxWalkSpeed of the character movement component. The MaxWalkSpeed is a variable that comes already with the Unreal Engine’s character and is automatically replicated, which means that when we change its value in the server, the new value is sent back to our client. The RPC also changes our variable IsRunPressed to True on the server, and this variable is also replicated back to the client. But this is a RepNotify variable, which means that every time it changes, the function OnRep_IsRunPressed is called (on server and clients) and inside this function you will see the code that tells the AnimBP (1st person and 3rd person) that IsRunPressed is now True. The AnimBP will then enter the state “Running” if the character is moving while IsRunPressed is True.

But on the client we don’t wait for these two values to arrive from the server, we go ahead and change them on the client before they arrive, so our character doesn’t feel laggy. When they arrive, they are set again but you don’t feel it because the values are the same. It’s just that the server must have the final decision. So please tell me if this answers your question.

It is. I be one of the types how wanna learn from these codes i sell on the Marketplace. I create a clean Project an wanna set it up as you code it. But my endresult is confuseing me.Look at the pic. I dont know why the character an the weapon aint communicate with eachother so that the weapon Spawn in the Hands an the animation get played from the anim_bp.

Look in the B_DemoCharacter blueprint, there is a macro called EquipWeapon. It’s called every time the variable CurrentWeapon changes (OnRep_CurrentWeapon is the function that calls it) and inside of it you will see the code that attaches the weapon mesh to the character’s socket and the code that tells the AnimBP which anims it should use inside the state machine.

You mean ‘purchase’ instead of ‘sell’, right?

Sorry for my bad english. Thank you for the help. Thank you.:o

In response to a question by Ctrl in the product page:

As a quick and dirty test, I’ve done this in the character blueprint. Z makes you instant lean left and X makes you instant lean right:

This is the result:

Updated to v1.3.5

Change log:

  • Updated to Unreal Engine v4.24

  • Small change in the method of calculation of ironsights. It now uses the node FindLookAtRotation followed by roll adjustment, instead of the dot products, RotationFromAxisAndAngle and CombineRotators nodes to find the direction from rear sight to front sight. The new method works better with the change implemented in v1.3.1 (since v1.3.1, the old method would let the rear sight a bit off depending on its location on the gun in relation to the front sight)

Updated to v1.4.0

Change log:

  • The name of the product was changed from “BP FPS Assault Rifle” to “Gun Assembly System”, to reflect the fact that the asset now allows building other guns too instead of being restricted to the original assault rifle

  • Implemented an UI widget (WB_Armory) that allows players to build guns with parts provided by you

  • Guns are now made of individual actors attached together, instead of components of one single actor

  • The gun mesh component isn’t a ‘PoseableMesh’ component anymore. It’s now a ‘SkeletalMesh’ component, with it’s own anim blueprint. This means the gun blueprint now can be used with any mesh, since it now doesn’t need to have the bone names hardcoded in it

  • Removed the option to use a HUD optic reticle as if it was the gun sight reticle. Now only reticles placed on the gun sights themselves are used, which avoids the need to set individual movement limits for each gun in order to prevent reticle being drawn in the air outside the gun sight. HUD reticles are not needed anyway, since the sight auto alignment already centralizes the sight’s aimpoint in front of the camera

  • The HUD widget functions that get the player input keys (for showing them on screen as tips) now don’t execute every tick anymore. Instead, they now only execute once at game start

  • Replaced the 3rd person anim montages with 3rd person anim sequences

  • UnEquip and Equip anims won’t play anymore when player tries to switch weapons if there are no weapons to switch to

Hi @PeaceSells_

I am wondering what kind of animations are you using for ADS? Have you done it in Maya/Blender?

Hey @bigfatblunt,

No, there are no ADS anim sequences. The anim blueprint gets the idle anim and procedurally move the hand bones to the right place, so the sights get aligned. This gives us the freedom to use virtually any gun and place virtually any sights anywhere on the gun, without having to make ADS anim sequences in Maya/Blender, etc. for each of them. You just need to make a normal idle anim for each gun.

Updated to v1.4.1

Change log:

  • Fixed: lack of smoothness when cycling between sights while aiming. Before, the interpolations were done through a Timeline in the character and the resulting values were applied in the EventBlueprintUpdateAnimation of the anim bp. Now everything is done in the anim bp, which fixed the lack of smoothness.

  • Deconflicted keys for rotating the gun and opening the customization menus in the Armory. Rotations are now done with the right or middle mouse buttons, while opening the menu is done with the left mouse button. This prevents opening menus accidentally while trying to rotate the gun.

  • Implemented an interface in the HUD for developers to adjust on the fly the max angle allowed for gun sights to be used for aiming (Developer Tools widget). Some guns have rails underneath (and in other places) that allow the placement of sights, but sights in those places yeld ugly arms poses when aiming.

Updated to v1.4.2

Change log:

  • Reduced number of nodes in the sight alignment code and in the interpolation when cycling between sights while aiming.

(The name of the product was changed from “Gun Assembly System” to “FPS Assemblable Gun”)

Hello. I just purchased FPS Assemblable Gun and I followed your tutorial with my own weapon mesh, but when I go to test it, I get an error that says “Can’t aim down sights, gun has no sights” There is also no model visible and when I try to add attachments Some of the sockets don’t work. Any ideas?

Edit: Fixed gun model being invisible and the sights not working, now just trying to fix sockets. But the gun is rotated 90 degrees.

Thanks,
Aerith

Hi @Aerith17, the gun rotated 90 deg should be a matter of just opening the character’s skeleton in the skeleton editor and rotating the socket in the hand_r bone to the desired position (in the included mannequin, this socket is called “Gun”). To make it easier to see it, also click on this socket, choose “Add Preview Asset” and the choose your own gun.

Regarding the attachment sockets not working, they have to follow the naming rules stated in the video correctly. There are 2 types of attachment sockets: Base, which must be present on the gun or part that will receive an attachment; and Mount, which must be present on the part that is the attachment itself.

There are 3 types of Base sockets: Point (for stuff like silencers, magazines. etc. that attach to a point) and RailStart and RailEnd (for stuff that you want to put on rails, usually optic sights, etc.). RailStart and RailEnd work in pairs, so if you place a RailStart without the corresponding RailEnd, it won’t work. Each RailStart must have a RailEnd with the same name.

There are 2 types of Mount sockets: Point (to be mounted on a point) and RailStart (to be mounted on rails). For any attachment to work, the name of its Mount socket must match the name of the Base socket it’s being mounted on. For example:

To mount a magazine on a gun, the magazine must have a socket named, for example:

Point_MyMag_Mount

and the gun must have a socket to receive it, named:

Point_MyMag_Base_1

You can replace “MyMag” with your desired name (as long as your desired name is the same on both the Mount and the Base sockets)

To mount an optic sight on a rail, the optic sight must have a socket named, for example:

RailStart_MyRail_Mount

and the gun must have two sockets to be able to receive it, named:

RailStart_MyRail_Base_1
RailEnd_MyRail_Base_1

You can replace “MyRail” with your desired name (as long as your desired name is the same on the Mount and the Base sockets)

Please tell me if you got the issues fixed.

Hello, I just purchased your asset and I really enjoy it but I have a few questions:

  1. How can I make it so that I keep aiming when I’m jumping/falling?
  2. Is there a way to make a shotgun-type gun that shoots multiple bullets at once?

I’m still new to UE4 so please excuse me if these questions are obvious.
Thank you!

@amdude_00 - Hi, I should have your answers shortly, thank you for your patience!

Hi, I’m replying to your response on the marketplace page, thanks for the reply! I tried to add the reload animations from the FPS assault pack for the AK. I was only able to play the actual weapons reload anim by playing the anim in the weapons child class on Event Reload. However in game when I reload it breaks the weapon system. Is there another way to play both the arms and weapon reload anim at the same time? Everything I have tried isn’t working, thank you!

Hello, I figured it out:

I had to modify the rule from Walking to InAir. Now it checks if the player is Falling and is NOT IsAiming.
Also, I had to remove the Exit Aiming function when the player switches MovementMode from Walking to Falling.
Now the player can keep aiming when falling

Edit:

I am now trying to get the player to be able to aim any time while they are in the air but I need some help. So far, when the player is in the air and I aim, the crosshair dissapears but the animation to aim down the sights never starts. Any ideas? Thank you.

@amdude_00 Hey man, I’m sorry I haven’t sent you anything yet. I did implement the keep aiming while in the air part and the enter aiming while in air part too, but I didn’t finish the shotgun fire part. These days have been kinda difficult here at home, I’ve had a mild COVID-19, but my father is in the hospital. On the next days things will probably slowly get back to normal though.

Regarding your last question, you have to go into the AB_DemoCharacter1P, go into the state machine and either:

  1. Remove the InAir state, since that state is active everytime your feet aren’t touching the ground, and that state only makes your character play the normal idle anim, with no option to go ADS. Removing this state will keep playing whatever anim your arms will be playing (running, idling, aiming) when you go into the air. The con is that your arms will keep running when you jump while running, but I don’t think this is very noticeable

  2. Copy-paste the ADS nodes from the Idle or Walking state, along with the blend node that allows you to aim, into the InAir state. That should work.

Regarding the shotgun fire, I was having some troulbe because the projectile blueprint (B_GunProjectile) in the project isn’t replicated. The way the project sends projectile impacts to the clients is indirectly through the gun blueprint that spawned the projectile, instead of trough the projectile blueprint itself. Since Unreal is optimized to not allow a bunch of Multicast events at the same time from the same Actor, the gun blueprint doesn’t transmit all the buckshot impacts to the clients. So I was about to make B_GunProjectile replicated too and move the code that replicates the impacts from the gun blueprint to B_GunProjectile, because that’s probably how I should’ve done it from start. But I had to interrupt working. I will still finish it and send it to you, but if you want to go ahead and try it anyway on your end, I’m here to try and help you.

See ya…