Skip to content

Latest commit

 

History

History

README.md

Shoot Projectile Down the Center of the Crosshair

  • Unreal Version: 5.0.0
  • Template: First Person
  • Project Name: MyProject

Big credit to the Shooter Game Project. It's a wonderful learning resource. I just tried to split out the weapon fire projectile code and simplify it so I could better understand it.

Screenshot

  1. Change Projectile Gravity Scale to 0 and set Initial Velocity in Local Space to false. Path: Content/FirstPersonCPP/Blueprints/FirstPersonProjectile Screenshot

  2. update the HUD.cpp file so the crosshair is in the center of screen. The crosshair texture is 16x16 so I adjusted it by 8 units in each direction on line 28. I think it's purposely off-center in the template to be more aligned with the yellow projectile, but I'm really not sure I could wrong.

  3. update the projectile files with an InitVelocity function.

  4. MyProjectCharacter.h - lines 141-148

  5. MyProjectCharacter.cpp- lines 149-180, and lines 315-351. you might have to include gameplay statics in your character file. I'm not sure, I didn't have to, I assume it's included by default. But if it throws an error, #include "Kismet/GameplayStatics.h" on line 14 might be necessary, but I can't confirm.

Helpful Links