I was following the tutorial in this thread [Tutorial] Weapon Essentials C++ Series - C++ Gameplay Programming - Unreal Engine Forums and got through part 1 and started part 2 only to find that I did not get nearly the same result as he did and literally none of what I did seems to be of any use (was a regular blueprint, not as depicted in the second part of the tutorial despite following all the steps to the letter and not getting any errors). I then followed this thread’s guide to updating code to more recent engine versions (4.6 Transition Guide - C++ Gameplay Programming - Unreal Engine Forums) but that has given me more problems than anything and no matter what I do it fails with errors. The code snippets it even uses in its error reporting is also incorrect from what I have. It says ‘const FObjectInitializer &’ but I put ‘const class FObjectInitializer&’.
The tutorial in that original thread seemed to be a great start to unreal engine c++ but doesn’t even work apparently. Can anyone help me out here?
error C2664: ‘AActor::AActor(const FObjectInitializer &)’ : cannot convert argument 1 from ‘const FObjectInitalizer’ to ‘const AActor &’
1> Reason: cannot convert from ‘const FObjectInitalizer’ to ‘const AActor’
1> No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
1>C:\Users\Kyle\Documents\Unreal Projects\CPPTest\Source\CPPTest\Weapon.cpp(15): error C2027: use of undefined type ‘FObjectInitalizer’
1> c:\users\kyle\documents\unreal projects\cpptest\source\cpptest\Weapon.h(53) : see declaration of ‘FObjectInitalizer’
1>C:\Users\Kyle\Documents\Unreal Projects\CPPTest\Source\CPPTest\Weapon.cpp(18): error C2027: use of undefined type ‘FObjectInitalizer’
1> c:\users\kyle\documents\unreal projects\cpptest\source\cpptest\Weapon.h(53) : see declaration of ‘FObjectInitalizer’
1> -------- End Detailed Actions Stats -----------------------------------------------------------
1>ERROR : UBT error : Failed to produce item: C:\Users\Kyle\Documents\Unreal Projects\CPPTest\Binaries\Win64\UE4Editor-CPPTest-8663-Win64-DebugGame.dll
1> Total build time: 28.07 seconds
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.MakeFile.Targets(38,5): error MSB3073: The command ““C:\Program Files\Epic Games\4.8\Engine\Build\BatchFiles\Build.bat” CPPTestEditor Win64 DebugGame “C:\Users\Kyle\Documents\Unreal Projects\CPPTest\CPPTest.uproject” -rocket” exited with code -1.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Weapons.h
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "GameFramework/Actor.h"
#include "Weapon.generated.h"
#define TRACE_WEAPON ECC_GameTraceChannel1 // defines our custom game trace channel
UENUM(BlueprintType)
namespace EWeaponProjectile
{
enum ProjectileType //projectile types
{
EBullet UMETA(DisplayName = "Bullet"),
ESpread UMETA(DisplayName = "Spread"),
EProjectile UMETA(DisplayName = "Projectile"),
};
}
USTRUCT()
struct FweaponData
{
GENERATED_USTRUCT_BODY()
UPROPERTY(EditDefaultsOnly, Category = Ammo)
int32 MaxAmmo;
UPROPERTY(EditDefaultsOnly, Category = Config)
float TimeBetweenShots;
UPROPERTY(EditDefaultsOnly, Category = Ammo)
float ShotCost;
UPROPERTY(EditDefaultsOnly, Category = Config)
float WeaponRange;
UPROPERTY(EditDefaultsOnly, Category = Config)
float WeaponSpread;
};
UCLASS()
class CPPTEST_API AWeapon : public AActor
{
//GENERATED_BODY()
GENERATED_UCLASS_BODY()
public:
// Sets default values for this actor's properties
AWeapon(const class FObjectInitalizer& ObjectInitializer);
// Called when the game starts or when spawned
//virtual void BeginPlay() override;
// Called every frame
//virtual void Tick( float DeltaSeconds ) override;
UFUNCTION()
void Fire();
UFUNCTION()
void Instant_Fire();
UPROPERTY(EditDefaultsOnly, Category = Config)
FweaponData WeaponConfig;
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = Config)
TEnumAsByte<EWeaponProjectile::ProjectileType> ProjectileType;
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Collision)
UBoxComponent* CollisionComp;
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Collision)
USkeletalMeshComponent* WeaponMesh;
protected:
FHitResult WeaponTrace(const FVector &TraceFrom, const FVector &TraceTo) const;
void ProcessInstantHit(const FHitResult &Impact, const FVector &Origin, const FVector &ShootDir, int32 RandomSeed, float ReticleSpread);
};
Weapon.cpp
// Fill out your copyright notice in the Description page of Project Settings.
#include "CPPTest.h"
#include "Weapon.h"
#include "Engine.h"
// Sets default values
AWeapon::AWeapon(const class FObjectInitalizer& ObjectInitializer)
: Super(ObjectInitializer)
{
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;
CollisionComp = ObjectInitializer.CreateDefaultSubobject<UBoxComponent>(this, TEXT("CollisionComp"));
RootComponent = CollisionComp;
WeaponMesh = ObjectInitializer.CreateDefaultSubobject<USkeletalMeshComponent>(this, TEXT("WeaponMesh"));
WeaponMesh->AttachTo(RootComponent);
}
void AWeapon::Fire()
{
if (ProjectileType == EWeaponProjectile::EBullet)
{
GEngine->AddOnScreenDebugMessage(-1, 2.f, FColor::Black, TEXT("Bullet"));
Instant_Fire();
}
if (ProjectileType == EWeaponProjectile::ESpread)
{
GEngine->AddOnScreenDebugMessage(-1, 2.f, FColor::Black, TEXT("Spread"));
for (int32 i = 0; i <= WeaponConfig.WeaponSpread; i++) {
Instant_Fire();
}
}
if (ProjectileType == EWeaponProjectile::EProjectile)
{
GEngine->AddOnScreenDebugMessage(-1, 2.f, FColor::Black, TEXT("Projectile"));
}
}
void AWeapon::Instant_Fire()
{
const int32 RandomSeed = FMath::Rand(); //generate random seed
FRandomStream WeaponRandomStream(RandomSeed);
const float CurrentSpread = WeaponConfig.WeaponSpread; //current weapon spread
const float SpreadCone = FMath::DegreesToRadians(WeaponConfig.WeaponSpread * 0.5);
const FVector AimDir = WeaponMesh->GetSocketRotation("mf").Vector(); //figure out our aim direction
const FVector StartTrace = WeaponMesh->GetSocketLocation("mf"); //starts trace
const FVector ShootDir = WeaponRandomStream.VRandCone(AimDir, SpreadCone, SpreadCone); //figure out our shoot direction
const FVector EndTrace = StartTrace + ShootDir * WeaponConfig.WeaponRange; // calculate difference between start direction and weapon range
const FHitResult Impact = WeaponTrace(StartTrace, EndTrace);
//Now these are all set up now we can actually process instant hit
ProcessInstantHit(Impact, StartTrace, ShootDir, RandomSeed, CurrentSpread);
}
/*
// Called when the game starts or when spawned
void AWeapon::BeginPlay()
{
Super::BeginPlay();
}
// Called every frame
void AWeapon::Tick( float DeltaTime )
{
Super::Tick( DeltaTime );
}*/
FHitResult AWeapon::WeaponTrace(const FVector &TraceFrom, const FVector &TraceTo) const
{
static FName WeaponFireTag = FName(TEXT("WeaponTrace"));
FCollisionQueryParams TraceParams(WeaponFireTag, true, Instigator);
TraceParams.bTraceAsyncScene = true;
TraceParams.bReturnPhysicalMaterial = true;
TraceParams.AddIgnoredActor(this);
FHitResult Hit(ForceInit);
GetWorld()->LineTraceSingleByChannel(Hit, TraceFrom, TraceTo, TRACE_WEAPON, TraceParams);
return Hit;
}
void AWeapon::ProcessInstantHit(const FHitResult &Impact, const FVector &Origin, const FVector &ShootDir, int32 RandomSeed, float ReticleSpread)
{
const FVector EndTrace = Origin + ShootDir * WeaponConfig.WeaponRange;
const FVector EndPoint = Impact.GetActor() ? Impact.ImpactPoint : EndTrace;
DrawDebugLine(this->GetWorld(), Origin, Impact.TraceEnd, FColor::Black, true, 10000, 10.0f);
}
Those are my modified versions in trying to follow the 4.6 transition guide linked above. If you want the original tutorial version I could revert back and post that for you.
It’s because you’re using the old GENERATED_UCLASS_BODY() which already defines the constructor. In addition to that, you’re also putting ‘class’ in front of FObjectInitializer which is causing it to be redefined. You shouldn’t ever need to do that.
(const FObjectInitializer& ObjectInitializer)
So yeah, either remove your constructor declaration in the header file or switch to GENERATED_BODY()
1>------ Build started: Project: CPPTest, Configuration: DebugGame_Editor x64 ------
1> Compiling game modules for hot reload
1> Parsing headers for CPPTestEditor
1> Reflection code generated for CPPTestEditor
1> Performing 3 actions (4 in parallel)
1> Weapon.cpp
1> CPPTest.generated.cpp
1>c:\users\kyle\documents\unreal projects\cpptest\source\cpptest\Weapon.h(46): error C2338: You have to define AWeapon::AWeapon() or AWeapon::AWeapon(const FObjectInitializer&). This is required by UObject system to work correctly.
1>c:\users\kyle\documents\unreal projects\cpptest\source\cpptest\Weapon.h(51): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\kyle\documents\unreal projects\cpptest\source\cpptest\Weapon.h(51): error C2143: syntax error : missing ',' before '&'
1>C:\Users\Kyle\Documents\Unreal Projects\CPPTest\Source\CPPTest\Weapon.h(46): error C2338: You have to define AWeapon::AWeapon() or AWeapon::AWeapon(const FObjectInitializer&). This is required by UObject system to work correctly.
1>C:\Users\Kyle\Documents\Unreal Projects\CPPTest\Source\CPPTest\Weapon.h(51): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>C:\Users\Kyle\Documents\Unreal Projects\CPPTest\Source\CPPTest\Weapon.h(51): error C2143: syntax error : missing ',' before '&'
1>C:\Users\Kyle\Documents\Unreal Projects\CPPTest\Source\CPPTest\Weapon.cpp(9): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>C:\Users\Kyle\Documents\Unreal Projects\CPPTest\Source\CPPTest\Weapon.cpp(9): error C2143: syntax error : missing ',' before '&'
1>C:\Users\Kyle\Documents\Unreal Projects\CPPTest\Source\CPPTest\Weapon.cpp(10): error C2065: 'ObjectInitializer' : undeclared identifier
1>C:\Users\Kyle\Documents\Unreal Projects\CPPTest\Source\CPPTest\Weapon.cpp(15): error C2065: 'ObjectInitializer' : undeclared identifier
1>C:\Users\Kyle\Documents\Unreal Projects\CPPTest\Source\CPPTest\Weapon.cpp(18): error C2065: 'ObjectInitializer' : undeclared identifier
1> -------- End Detailed Actions Stats -----------------------------------------------------------
1>ERROR : UBT error : Failed to produce item: C:\Users\Kyle\Documents\Unreal Projects\CPPTest\Binaries\Win64\UE4Editor-CPPTest-2805-Win64-DebugGame.dll
1> Total build time: 82.87 seconds
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.MakeFile.Targets(38,5): error MSB3073: The command ""C:\Program Files\Epic Games\4.8\Engine\Build\BatchFiles\Build.bat" CPPTestEditor Win64 DebugGame "C:\Users\Kyle\Documents\Unreal Projects\CPPTest\CPPTest.uproject" -rocket" exited with code -1.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
After reading that log I then changed my declaration in the header file to AWeapon::AWeapon(const FObjectInitializer& ObjectInitializer) and tried again to get this error log:
1>------ Build started: Project: CPPTest, Configuration: DebugGame_Editor x64 ------
1> Compiling game modules for hot reload
1> Parsing headers for CPPTestEditor
1> Reflection code generated for CPPTestEditor
1> Performing 3 actions (4 in parallel)
1> Weapon.cpp
1> CPPTest.generated.cpp
1>c:\users\kyle\documents\unreal projects\cpptest\source\cpptest\Weapon.h(51): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\kyle\documents\unreal projects\cpptest\source\cpptest\Weapon.h(51): error C2143: syntax error : missing ',' before '&'
1>C:\Users\Kyle\Documents\Unreal Projects\CPPTest\Source\CPPTest\Weapon.h(51): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>C:\Users\Kyle\Documents\Unreal Projects\CPPTest\Source\CPPTest\Weapon.h(51): error C2143: syntax error : missing ',' before '&'
1>C:\Users\Kyle\Documents\Unreal Projects\CPPTest\Source\CPPTest\Weapon.cpp(9): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>C:\Users\Kyle\Documents\Unreal Projects\CPPTest\Source\CPPTest\Weapon.cpp(9): error C2143: syntax error : missing ',' before '&'
1>C:\Users\Kyle\Documents\Unreal Projects\CPPTest\Source\CPPTest\Weapon.cpp(10): error C2065: 'ObjectInitializer' : undeclared identifier
1>C:\Users\Kyle\Documents\Unreal Projects\CPPTest\Source\CPPTest\Weapon.cpp(15): error C2065: 'ObjectInitializer' : undeclared identifier
1>C:\Users\Kyle\Documents\Unreal Projects\CPPTest\Source\CPPTest\Weapon.cpp(18): error C2065: 'ObjectInitializer' : undeclared identifier
1> -------- End Detailed Actions Stats -----------------------------------------------------------
1>ERROR : UBT error : Failed to produce item: C:\Users\Kyle\Documents\Unreal Projects\CPPTest\Binaries\Win64\UE4Editor-CPPTest-7185-Win64-DebugGame.dll
1> Total build time: 26.93 seconds
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.MakeFile.Targets(38,5): error MSB3073: The command ""C:\Program Files\Epic Games\4.8\Engine\Build\BatchFiles\Build.bat" CPPTestEditor Win64 DebugGame "C:\Users\Kyle\Documents\Unreal Projects\CPPTest\CPPTest.uproject" -rocket" exited with code -1.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Okay so, are you using GENERATED_BODY() now or GENERATED_UCLASS_BODY()?
It doesn’t seem to know what ‘AWeapon’ actually is, so I’m starting to wonder if the problem is further up the header file - probably with the declaration of a namespace. Try defining your enum like this first of all (this is the way it’s meant to be):
UCLASS()
class CPPTEST_API AWeapon : public AActor
{
GENERATED_BODY()
//GENERATED_UCLASS_BODY()
public:
// Sets default values for this actor's properties
AWeapon();
AWeapon::AWeapon() : Super()
{
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;
CollisionComp = CreateDefaultSubobject<UBoxComponent>(TEXT("CollisionComp"));
RootComponent = CollisionComp;
WeaponMesh = CreateDefaultSubobject<USkeletalMeshComponent>(TEXT("WeaponMesh"));
WeaponMesh->AttachTo(RootComponent);
}
1>------ Build started: Project: CPPTest, Configuration: DebugGame_Editor x64 ------
1> Compiling game modules for hot reload
1> Parsing headers for CPPTestEditor
1> Reflection code generated for CPPTestEditor
1> Performing 3 actions (4 in parallel)
1> Weapon.cpp
1> CPPTest.generated.cpp
1>c:\users\kyle\documents\unreal projects\cpptest\source\cpptest\Weapon.h(50): error C2590: 'FWeaponData' : only a constructor can have a base/member initializer list
1>c:\users\kyle\documents\unreal projects\cpptest\source\cpptest\Weapon.h(85): error C2838: 'ProjectileType' : illegal qualified name in member declaration
1>c:\users\kyle\documents\unreal projects\cpptest\source\cpptest\Weapon.h(85): error C2065: 'ProjectileType' : undeclared identifier
1>c:\users\kyle\documents\unreal projects\cpptest\source\cpptest\Weapon.h(85): error C2923: 'TEnumAsByte' : 'ProjectileType' is not a valid template type argument for parameter 'TEnum'
1>C:\Users\Kyle\Documents\Unreal Projects\CPPTest\Source\CPPTest\Weapon.h(50): error C2590: 'FWeaponData' : only a constructor can have a base/member initializer list
1>C:\Users\Kyle\Documents\Unreal Projects\CPPTest\Source\CPPTest\Weapon.h(85): error C2838: 'ProjectileType' : illegal qualified name in member declaration
1>C:\Users\Kyle\Documents\Unreal Projects\CPPTest\Source\CPPTest\Weapon.h(85): error C2065: 'ProjectileType' : undeclared identifier
1>C:\Users\Kyle\Documents\Unreal Projects\CPPTest\Source\CPPTest\Weapon.h(85): error C2923: 'TEnumAsByte' : 'ProjectileType' is not a valid template type argument for parameter 'TEnum'
1>C:\Users\Kyle\Documents\Unreal Projects\CPPTest\Intermediate\Build\Win64\UE4Editor\Inc\CPPTest\CPPTest.generated.cpp(453): error C2512: 'TEnumAsByte' : no appropriate default constructor available
1>C:\Users\Kyle\Documents\Unreal Projects\CPPTest\Source\CPPTest\Weapon.cpp(12): error C2512: 'TEnumAsByte' : no appropriate default constructor available
1>C:\Users\Kyle\Documents\Unreal Projects\CPPTest\Source\CPPTest\Weapon.cpp(31): error C2678: binary '==' : no operator found which takes a left-hand operand of type 'TEnumAsByte' (or there is no acceptable conversion)
1> C:\Program Files\Epic Games\4.8\Engine\Source\Runtime\Core\Public\Containers\EnumAsByte.h(98): could be 'bool TEnumAsByte<TEnum>::operator ==(TEnumAsByte<TEnum>) const'
1> C:\Program Files\Epic Games\4.8\Engine\Source\Runtime\Core\Public\Containers\EnumAsByte.h(87): or 'bool TEnumAsByte<TEnum>::operator ==(TEnum) const'
1> C:\Program Files\Epic Games\4.8\Engine\Source\Runtime\Engine\Classes\Sound/DialogueWave.h(36): or 'bool operator ==(const FDialogueContextMapping &,const FDialogueContextMapping &)'
1> C:\Program Files\Epic Games\4.8\Engine\Source\Runtime\Engine\Classes\Sound/DialogueTypes.h(56): or 'bool operator ==(const FDialogueContext &,const FDialogueContext &)'
1> C:\Program Files\Epic Games\4.8\Engine\Source\Runtime\Engine\Classes\Engine/StaticMesh.h(209): or 'bool operator ==(const FMeshSectionInfo &,const FMeshSectionInfo &)'
1> C:\Program Files\Epic Games\4.8\Engine\Source\Runtime\Engine\Classes\Engine/SkeletalMesh.h(514): or 'bool operator ==(const UMaterialInterface &,const FSkeletalMaterial &)'
1> C:\Program Files\Epic Games\4.8\Engine\Source\Runtime\Engine\Classes\Engine/SkeletalMesh.h(513): or 'bool operator ==(const FSkeletalMaterial &,const UMaterialInterface &)'
1> C:\Program Files\Epic Games\4.8\Engine\Source\Runtime\Engine\Classes\Engine/SkeletalMesh.h(512): or 'bool operator ==(const FSkeletalMaterial &,const FSkeletalMaterial &)'
1> c:\program files\epic games\4.8\engine\source\runtime\rhi\public\RHIResources.h(179): or 'bool operator ==(const FRHIUniformBufferLayout &,const FRHIUniformBufferLayout &)'
1> C:\Program Files (x86)\Windows Kits\8.1\include\shared\guiddef.h(192): or 'bool operator ==(const GUID &,const GUID &)'
1> while trying to match the argument list '(TEnumAsByte, EWeaponProjectile)'
1>C:\Users\Kyle\Documents\Unreal Projects\CPPTest\Source\CPPTest\Weapon.cpp(36): error C2678: binary '==' : no operator found which takes a left-hand operand of type 'TEnumAsByte' (or there is no acceptable conversion)
1> C:\Program Files\Epic Games\4.8\Engine\Source\Runtime\Core\Public\Containers\EnumAsByte.h(98): could be 'bool TEnumAsByte<TEnum>::operator ==(TEnumAsByte<TEnum>) const'
1> C:\Program Files\Epic Games\4.8\Engine\Source\Runtime\Core\Public\Containers\EnumAsByte.h(87): or 'bool TEnumAsByte<TEnum>::operator ==(TEnum) const'
1> C:\Program Files\Epic Games\4.8\Engine\Source\Runtime\Engine\Classes\Sound/DialogueWave.h(36): or 'bool operator ==(const FDialogueContextMapping &,const FDialogueContextMapping &)'
1> C:\Program Files\Epic Games\4.8\Engine\Source\Runtime\Engine\Classes\Sound/DialogueTypes.h(56): or 'bool operator ==(const FDialogueContext &,const FDialogueContext &)'
1> C:\Program Files\Epic Games\4.8\Engine\Source\Runtime\Engine\Classes\Engine/StaticMesh.h(209): or 'bool operator ==(const FMeshSectionInfo &,const FMeshSectionInfo &)'
1> C:\Program Files\Epic Games\4.8\Engine\Source\Runtime\Engine\Classes\Engine/SkeletalMesh.h(514): or 'bool operator ==(const UMaterialInterface &,const FSkeletalMaterial &)'
1> C:\Program Files\Epic Games\4.8\Engine\Source\Runtime\Engine\Classes\Engine/SkeletalMesh.h(513): or 'bool operator ==(const FSkeletalMaterial &,const UMaterialInterface &)'
1> C:\Program Files\Epic Games\4.8\Engine\Source\Runtime\Engine\Classes\Engine/SkeletalMesh.h(512): or 'bool operator ==(const FSkeletalMaterial &,const FSkeletalMaterial &)'
1> c:\program files\epic games\4.8\engine\source\runtime\rhi\public\RHIResources.h(179): or 'bool operator ==(const FRHIUniformBufferLayout &,const FRHIUniformBufferLayout &)'
1> C:\Program Files (x86)\Windows Kits\8.1\include\shared\guiddef.h(192): or 'bool operator ==(const GUID &,const GUID &)'
1> while trying to match the argument list '(TEnumAsByte, EWeaponProjectile)'
1>C:\Users\Kyle\Documents\Unreal Projects\CPPTest\Source\CPPTest\Weapon.cpp(43): error C2678: binary '==' : no operator found which takes a left-hand operand of type 'TEnumAsByte' (or there is no acceptable conversion)
1> C:\Program Files\Epic Games\4.8\Engine\Source\Runtime\Core\Public\Containers\EnumAsByte.h(98): could be 'bool TEnumAsByte<TEnum>::operator ==(TEnumAsByte<TEnum>) const'
1> C:\Program Files\Epic Games\4.8\Engine\Source\Runtime\Core\Public\Containers\EnumAsByte.h(87): or 'bool TEnumAsByte<TEnum>::operator ==(TEnum) const'
1> C:\Program Files\Epic Games\4.8\Engine\Source\Runtime\Engine\Classes\Sound/DialogueWave.h(36): or 'bool operator ==(const FDialogueContextMapping &,const FDialogueContextMapping &)'
1> C:\Program Files\Epic Games\4.8\Engine\Source\Runtime\Engine\Classes\Sound/DialogueTypes.h(56): or 'bool operator ==(const FDialogueContext &,const FDialogueContext &)'
1> C:\Program Files\Epic Games\4.8\Engine\Source\Runtime\Engine\Classes\Engine/StaticMesh.h(209): or 'bool operator ==(const FMeshSectionInfo &,const FMeshSectionInfo &)'
1> C:\Program Files\Epic Games\4.8\Engine\Source\Runtime\Engine\Classes\Engine/SkeletalMesh.h(514): or 'bool operator ==(const UMaterialInterface &,const FSkeletalMaterial &)'
1> C:\Program Files\Epic Games\4.8\Engine\Source\Runtime\Engine\Classes\Engine/SkeletalMesh.h(513): or 'bool operator ==(const FSkeletalMaterial &,const UMaterialInterface &)'
1> C:\Program Files\Epic Games\4.8\Engine\Source\Runtime\Engine\Classes\Engine/SkeletalMesh.h(512): or 'bool operator ==(const FSkeletalMaterial &,const FSkeletalMaterial &)'
1> c:\program files\epic games\4.8\engine\source\runtime\rhi\public\RHIResources.h(179): or 'bool operator ==(const FRHIUniformBufferLayout &,const FRHIUniformBufferLayout &)'
1> C:\Program Files (x86)\Windows Kits\8.1\include\shared\guiddef.h(192): or 'bool operator ==(const GUID &,const GUID &)'
1> while trying to match the argument list '(TEnumAsByte, EWeaponProjectile)'
1> -------- End Detailed Actions Stats -----------------------------------------------------------
1>ERROR : UBT error : Failed to produce item: C:\Users\Kyle\Documents\Unreal Projects\CPPTest\Binaries\Win64\UE4Editor-CPPTest-1545-Win64-DebugGame.dll
1> Total build time: 26.59 seconds
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.MakeFile.Targets(38,5): error MSB3073: The command ""C:\Program Files\Epic Games\4.8\Engine\Build\BatchFiles\Build.bat" CPPTestEditor Win64 DebugGame "C:\Users\Kyle\Documents\Unreal Projects\CPPTest\CPPTest.uproject" -rocket" exited with code -1.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
EDIT: After some good ol’ debugging I got it to successfully generate but I am STILL no better off than before and I am now back to the original issue. I am unable to create a sub blueprint class from the Weapon C++ class in the sense that it is not custom made and is the generic old blueprint when creating them default. This one (as depicted early in the second part of the tutorial series) should be entirely different with components already in place.
Well, I compiled it and it worked perfectly first time. No code changes whatsoever.
I recommend refreshing the project. Delete the Intermediate, Saved, Binaries and Build folder. Also delete all the files in the main folder apart from the Unreal Project File. Then switch to engine version 4.8 and regenerate project files, should be fine! Sometimes a good refresh is all it needs.
Now I continued following along (had to switch to a third person project though due to it all being weird in first person project and that fixed weirdness) but now I keep getting the error ‘Unhandled exception at 0x000007FED8CE3CDE (UE4Editor-WeaponEssentials-5317.dll) in UE4Editor.exe: 0xC0000005: Access violation reading location 0x0000000000000370.’ And the engine crashes. I am not sure what is going on.
I have included my code from the source folder. Please ignore the Achievements class as it is not called anywhere nor relevant and was just something I made while I was bored for the fun of it (and error occurred before it was added).
That usually refers to a variable that has been garbage collected, or doesn’t exist. It’s basically saying it’s tried to access memory that it can’t get to or doesn’t exist. Again, I can have a quick look later.
I noticed that your struct is called FweaponData but the constructor is FWeaponData. Pretty certain that constructors are case sensitive. You might want to rectify that.
In addition, try placing the weapon.h include under the engine.h include.
In the updated scripts (which you can download for yourself here: http://dl.markyrosongaming.ar.nf/UE4/Source.zip) the first issue you mentioned is resolved. I tried moving the includes around but it created a fatal error when I tried to build the source.