What I will do:
- Add shotgun that will fire couple of shells,
- Projectiles will bounce,
- Add damage variables to Shotgun and Reaper,
- Add spread to Shotgun and Reaper,
As I said earlier the game will be about surviving - there will be couple of enemy types and each type will have his weak point, that will motivate player to change weapon during gameplay.
Add Shotgun and enable projectile bouncing
if you weren't reading earlier post please read how I have added Reaper weapon.
Here's great sci-fi weapon pack from Stronghold Creative
Sci-fi weapon pack from Stronghold Creative. Easy to import to UE4! |
- Add another variable to your WeaponType Enum,
- Add new socket for Shotgun,
- Use your ChangeWeapon function to set static mesh and attach weapon to socket,
- Change Posts Begin Play function to use Shotgun, not reaper.
At this point you will have your Shotgun spawned in game. Create a copy of MyProjectile and name it Shotgun_Projectile. Open it.
1. Break link from Post Begin Play - we will use different settings there,
2. In Event Hit - destroy link to Spawn Emitter and Play Sound,
1. Break link from Post Begin Play - we will use different settings there,
2. In Event Hit - destroy link to Spawn Emitter and Play Sound,
3. Go to Components,
4. Select Projectile Component,
5. Find projectile bounces category and set it to true, leave values as it,
Basically Epic created bounces for us so you don't even do it by yourself like here:
4. Select Projectile Component,
5. Find projectile bounces category and set it to true, leave values as it,
Basically Epic created bounces for us so you don't even do it by yourself like here:
You can implement bounciness like this but it isn't needed. UE4 can do it for us. |
6. Go back to MyCharacter blueprint and implement shoot functionality for shotgun. Just simple spawn Shotgun_Projectile. You can test out bouncing at this point.
Add spread to Shotgun and Reaper
Do the same on both weapons for spawning Projectile translation.
Do the same on both weapons for spawning Projectile translation.
Epic have another way to do this:
Shotgun - firing couple of shells
This will be super easy. First create int variable Shells and set it to 6.
1. Create For Loop block before spawning Shotgun Projectile,
This will be super easy. First create int variable Shells and set it to 6.
1. Create For Loop block before spawning Shotgun Projectile,
2. Assign Shells to LastIndex,
3. Use For Loop to spawn Projectiles as here:
3. Use For Loop to spawn Projectiles as here:
Add Damage - Reaper
Open MyCharacter blueprint and add two int variables: Reaper_MinDamage (default 20) and Reaper_MaxDamage (default 40) add those variables to Weapon_Reaper category. It will be easier to find them later.
Open MyProjectile blueprint (which is Reaper projectile) and add the same variables. Make sure Expose on Spawn is set to true for both of them.
Go back to MyCharacter blueprint and update Spawn Actor MyProjectile block. You will see created variables in MyProjectile. Connect Reaper_MinDamage and Reaper_MaxDamage to it.
In MyProjectile create Rand Range block and assing Min and Max damage variables to it. You can use Print String to check damage variables.
That's all for now - we will use those variables when dealing damage to enemies and when upgrading weapons.
Add Damage - Shotgun
Just do the same like in Reaper. Try by yourself!
So yeah we have an Shotgun functionality ready! Experiment with different settings to get better results. (you should change lifetime of Shotgun Projectile to lower value - you can change that in Defaults -> Initial Life Span.)
Add Damage - Shotgun
Just do the same like in Reaper. Try by yourself!
So yeah we have an Shotgun functionality ready! Experiment with different settings to get better results. (you should change lifetime of Shotgun Projectile to lower value - you can change that in Defaults -> Initial Life Span.)
Another thing is that you can limit bounces using int like here (it's event hit from shotgun projectile):
Here's shotgun functionality:
In next post we will be adding effects to it and different recoil.
No comments:
Post a Comment