I’m having issues implementing my TakeDamage function override for my character class. The “DamageEvent” struct won’t allow me to call it’s “GetBestHitInfo” public function to gather data on HitResult and HitDirection.
The error I’m getting is “Incomplete class type FDamageEvent is not allowed”.
I have Pawn.h, Actor.h, and even EngineTypes.h but my code still won’t compile for the use of an undefined type.
You can forward-declare the struct in .h to avoid including additional headers, but you have to do forward-declarations outside of the class declaration, otherwise you are declaring it within its namespace and it’s treated as a new type, eg. AMainCharacter::FDamageEvent instead of just FDamageEvent.
I forward declared the struct outside of the class but I’m still getting the same error.
This doesn’t make sense because anywhere else in my code, Intellisense recognizes FDamageEvent as a struct so I would think that it’s not an incomplete type, unless I’m not fully understanding how Intellisense works.
Do you think it has something to do with how I’m using DamageEvent in my code?
My compiler also shows these two errors if this helps:
1>D:\Game Development\Unreal Projects\Siege\Source\Siege\Character\MainCharacter\MainCharacter.cpp(394): error C2027: use of undefined type ‘FDamageEvent’
1>C:\Program Files\Epic Games\UE_5.1\Engine\Source\Runtime\Engine\Classes\GameFramework\Actor.h(3230): note: see declaration of ‘FDamageEvent’
line from my Editor.Target.cs it removes the error. I only added this due to a compiler recommendation since I converted my project from UE5 to UE5.1
Any ideas why this would happen? Here’s the entire code:
using UnrealBuildTool;
using System.Collections.Generic;
public class GameEditorTarget : TargetRules
{
public GameEditorTarget( TargetInfo Target) : base(Target)
{
Type = TargetType.Editor;
DefaultBuildSettings = BuildSettingsVersion.V2;
IncludeOrderVersion = EngineIncludeOrderVersion.Unreal5_1;
ExtraModuleNames.AddRange( new string[] { "Game" } );
}
}
I found that just including “Engine/DamageEvents.h” fixed a similar compile error for me (having also just adding the recommended Editor.Target.cs line myself).