Unreal Engine 5 C++ Help Weapon Not Attaching / Pawn Not Ap…

Im working on a C++ Unreal Engine 5 assignment involving a BaseCharacter, Rifle, and Projectile system. The project compiles successfully, but the behavior is incorrect and Im stuck at the same point for the second submission attempt.

Below is the instructor feedback I received:

Base Character (18 pts) 11/18

  • No ChildActorComponent used (was using SpawnActor and AttachToComponent directly)
  • ChildActorComponent pointer not declared in header
  • AnimBP pointer not declared in header
  • Missing mesh location/rotation setup in constructor
  • Missing AnimBP caching in BeginPlay
  • Weapon object must be set before checking for nullptr
  • Must use ChildActorComponent with SetupAttachment and SetChildActorClass

Rifle (8 pts) 6/8

  • No FName variable declared
  • SkeletalMeshComponent must be declared in the header (not using FindComponentByClass)
  • Proper casting and ownership setup required

Projectile (24 pts) 23/24

  • Timer uses hardcoded 3.0f instead of declared float variable

Current issues:

  • The pawn does not appear correctly when playing (or behaves unexpectedly when ejecting)
  • The weapon does not attach/render properly
  • The ChildActorComponent behavior may be incorrect
  • Firing behavior is inconsistent
  • Everything compiles successfully

Assignment requirements include:

  • Using UChildActorComponent for the weapon (no direct SpawnActor)
  • Attaching the weapon to a skeletal mesh socket
  • Spawning the projectile from a muzzle socket
  • Converting AnimBP logic from Blueprint to C++
  • Proper separation of logic between BaseCharacter and Rifle

I am attaching the relevant C++ files:

  • BaseCharacter.h / .cpp
  • Rifle.h / .cpp
  • Projectile.h / .cpp

I am needing someone to help me correct the structural and logic errors directly in the code, and explain what is causing the pawn and weapon to behave incorrectly.

Thank you.

Requirements: Detailed

WRITE MY PAPER


Comments

Leave a Reply