<?xml version="1.0" encoding="UTF-8" standalone="yes"?><oembed><version><![CDATA[1.0]]></version><provider_name><![CDATA[Shooter Game Tutorial]]></provider_name><provider_url><![CDATA[http://shootertutorial.com]]></provider_url><author_name><![CDATA[andrzejkoloska]]></author_name><author_url><![CDATA[https://shootertutorial.com/author/andrzejkoloska/]]></author_url><title><![CDATA[Creating Assault Rifle]]></title><type><![CDATA[link]]></type><html><![CDATA[<p><a href="http://shootertutorial.com/2015/06/19/creating-an-assault-rifle/"><img class="alignnone wp-image-531 size-full" src="https://shootertutorial.files.wordpress.com/2015/06/riflescreen1.jpg?w=659&#038;h=434" alt="riflescreen1" width="659" height="434" /></a></p>
<p>BasicWeapon blueprint now supports a lot but it isn&#8217;t supporting automatic fire like assault rifles have. It will be really simple to implement now.</p>
<ul>
<li>Rifle should use automatic fire,</li>
<li>We will use existing functionalities to drive this weapon,</li>
</ul>
<p>Basically I will implement almost all of the weapons from <a href="https://www.unrealengine.com/content/b5db9911879141e99f8c34fb14b66691" target="_blank">Military Silver Pack</a> and then move forward with gameplay. I want to have BasicWeapon functionalities fully implemented and tested out.</p>
<p><!--more--></p>
<pre><strong>This Tutorial has been created using Unreal Engine 4.8.2</strong>. 
Make sure you are working on the same version of the engine.</pre>
<p>For those who haven&#8217;t read earlier posts you should implement BasicWeapon blueprint to get this working. So check out earlier posts!</p>
<p><strong>Stop Fire functionality</strong></p>
<p>Add one new dispatcher to GameplayCharacter: OnWeaponStopFireWeapon (inputs WeaponType)</p>
<p>Now in BP_BaseWeapon</p>
<p>Add one new variable:</p>
<ul>
<li>RiflesFireRate (float, default 0.1)</li>
</ul>
<p>And one new function:</p>
<ul>
<li>StopFire, &#8211; leave it blank,</li>
</ul>
<p>Go back to GameplayCharacter and add new custom event: StopFire.</p>
<p><a href="https://shootertutorial.files.wordpress.com/2015/06/stopfireinput.jpg"><img class="alignnone size-medium wp-image-525" src="https://shootertutorial.files.wordpress.com/2015/06/stopfireinput.jpg?w=300&#038;h=190" alt="stopfireinput" width="300" height="190" /></a></p>
<p>So now we are driving input (only PC for now)</p>
<p><strong>Creating Weapon</strong></p>
<p>Go to BP_Weapon_AssaultRifle (we had created it <a href="http://shootertutorial.com/2015/06/08/how-to-add-weapons-basics-equipping/">earlier</a>) and fill variables:</p>
<ul>
<li>CurrentAmmoInMag: 30,</li>
<li>MaxAmmoInMag: 30,</li>
<li>CurrentAmmoInBackpack: 100,</li>
<li>MaxAmmoInBackpack: 100,</li>
<li>SpreadMin: 0.02,</li>
<li>SpreadMax: 0.2,</li>
<li>SpreadCurrent: 0.1,</li>
<li>SpreadDecreaseSpeed: 0.25,</li>
<li>MinWeaponDamageModifier: 0.7,</li>
<li>MaxWeaponDamageModifier: 1.2,</li>
<li>CritDamageModifier: 3,</li>
</ul>
<p>Add one new variable:</p>
<ul>
<li>IsRifleFiring (bool),</li>
</ul>
<p>Now in event graph:</p>
<p><a href="https://shootertutorial.files.wordpress.com/2015/06/riflebp_graph.jpg"><img class="alignnone size-medium wp-image-526" src="https://shootertutorial.files.wordpress.com/2015/06/riflebp_graph.jpg?w=300&#038;h=151" alt="riflebp_graph" width="300" height="151" /></a></p>
<p>And that&#8217;s whole rifle functionality <span class='wp-smiley wp-emoji wp-emoji-smile' title=':)'>:)</span> We are using timer to make automatic fire. It&#8217;s really easy.</p>
<p><strong>Creating Animation</strong></p>
<p>In HeroFPP_AnimationBlueprint. If you were reading earlier posts you should be able to do this by yourself. It&#8217;s the same thing:</p>
<ul>
<li>Position hands to fit the weapon,</li>
<li>Use RifleRecoil bool to drive the recoil bone modify alpha,</li>
</ul>
<p>So, create two new variables like in earlier post:</p>
<ul>
<li>RifleRecoil (bool),</li>
<li>RifleRecoilAlpha (float)</li>
</ul>
<p>Now in event Initialize Animation we need to know when we are firing and when firing ends.</p>
<p><a href="https://shootertutorial.files.wordpress.com/2015/06/animbpbeginplay.jpg"><img class="alignnone size-medium wp-image-527" src="https://shootertutorial.files.wordpress.com/2015/06/animbpbeginplay.jpg?w=300&#038;h=211" alt="animbpbeginplay" width="300" height="211" /></a></p>
<p>And in Update Animation let&#8217;s drive RifleRecoilAlpha</p>
<p><a href="https://shootertutorial.files.wordpress.com/2015/06/animbpriflerecoil.jpg"><img class="alignnone size-medium wp-image-528" src="https://shootertutorial.files.wordpress.com/2015/06/animbpriflerecoil.jpg?w=300&#038;h=119" alt="animbpriflerecoil" width="300" height="119" /></a></p>
<p>Anim graph should take RifleRecoilAlpha and modify bone.</p>
<p><a href="https://shootertutorial.files.wordpress.com/2015/06/riflerecoil.jpg"><img class="alignnone size-medium wp-image-529" src="https://shootertutorial.files.wordpress.com/2015/06/riflerecoil.jpg?w=300&#038;h=116" alt="riflerecoil" width="300" height="116" /></a></p>
<p>Final result:</p>
<p><span class='embed-youtube' style='text-align:center; display: block;'><iframe class='youtube-player' type='text/html' width='640' height='390' src='https://www.youtube.com/embed/uaoNG_KuMaQ?version=3&#038;rel=1&#038;fs=1&#038;showsearch=0&#038;showinfo=1&#038;iv_load_policy=1&#038;wmode=transparent' frameborder='0' allowfullscreen='true'></iframe></span></p>
]]></html><thumbnail_url><![CDATA[https://i2.wp.com/shootertutorial.files.wordpress.com/2015/06/riflescreen1.jpg?fit=440%2C330]]></thumbnail_url><thumbnail_height><![CDATA[289]]></thumbnail_height><thumbnail_width><![CDATA[440]]></thumbnail_width></oembed>